博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Win8Metro(C#)数字图像处理--2.20图像垂直镜像
阅读量:6887 次
发布时间:2019-06-27

本文共 977 字,大约阅读时间需要 3 分钟。

原文:



[函数名称]

图像垂直镜像函数MirrorYProcess(WriteableBitmap src)

[函数代码]

       ///<summary>

       /// Vertical mirror process.

       ///</summary>

       ///<param name="src">Source image.</param>

       ///<returns></returns>

       publicstaticWriteableBitmap MirrorYProcess(WriteableBitmap src)20垂直镜像

       {

           if(src!=null )

           {

           int w = src.PixelWidth;

           int h = src.PixelHeight;

           WriteableBitmap mirrorImage =newWriteableBitmap(w,h);

           byte[] temp = src.PixelBuffer.ToArray();

           byte[] tempMask =newbyte[w * h * 4];

           for (int i = 0; i < w; i++)

           {

               for (int j = 0; j < h; j++)

               {

                   tempMask[i * 4 + j * w * 4] = temp[i * 4 + (h - 1 - j) * w * 4];

                   tempMask[i * 4 + 1 + j * w * 4] = temp[i * 4 + 1 + (h - 1 - j) * w * 4];

                   tempMask[i * 4 + 2 + j * w * 4] = temp[i * 4 + 2 + (h - 1 - j) * w * 4];

                   tempMask[i * 4 + 3 + j * w * 4] = temp[i * 4 + 3 + (h - 1 - j) * w * 4];

               }

           }         

           Stream sTemp = mirrorImage.PixelBuffer.AsStream();

           sTemp.Seek(0, SeekOrigin.Begin);

           sTemp.Write(tempMask, 0, w * 4 * h);

           return mirrorImage;

           }

           else

           {

               returnnull;

           }            

       }

[图像效果]

你可能感兴趣的文章
微信,是怎么过来的(2010-2015)
查看>>
NGINX 添加MP4、FLV视频支持模块
查看>>
Apache Flink fault tolerance源码剖析(二)
查看>>
C#实现字符串按多个字符采用Split方法分割
查看>>
Linux学习--&gt;如何通过Shell脚本实现发送邮件通知功能?
查看>>
python 类
查看>>
《Linux From Scratch》第二部分:准备构建 第五章:构建临时文件系统- 5.1 简介
查看>>
学习笔记TF061:分布式TensorFlow,分布式原理、最佳实践
查看>>
CBinsights:不只是金融,区块链还可以改变这30个行业
查看>>
彻底厘清真实世界中的分布式系统
查看>>
HybridDB for PostgreSQL上手指南
查看>>
『0013』 - Solidity Types - 固定大小字节数组(Fixed-size byte arrays)
查看>>
java-并发-ConcurrentHashMap高并发机制-jdk1.6
查看>>
Kubernetes之服务质量保证(QoS)
查看>>
大数据业务应用场景
查看>>
低带宽DDoS攻击可瘫痪防火墙
查看>>
IBM云计算扩展在华Bluemix生态系统
查看>>
大数据+人工智能定义语音质检
查看>>
制造业大数据分析打造新一代智能工厂
查看>>
存储界谁可以取代EMC?
查看>>