原文:Win8Metro(C#)数字图像处理--2.18图像平移变换



[函数名称]

图像平移变换函数TranslationProcess(WriteableBitmap src,int x,int y)

[函数代码]

///<summary>

/// Translation process.

///</summary>

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

///<param name="x">Translate value of x.</param>

///<param name="y">Translate value of y.</param>

///<returns></returns>

publicstaticWriteableBitmap TranslationProcess(WriteableBitmap src,int x,int y)18平移变换

{

if(src!=null )

{

int w = src.PixelWidth;

int h = src.PixelHeight;

WriteableBitmap translateImage =newWriteableBitmap(w, h);

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

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

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

{

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

{

if (i + x < 0 || i + x >= w || j + y < 0 || j + y >= h)

{

tempMask[i * 4 + j * w * 4] = (byte)0;

tempMask[i * 4 + 1 + j * w * 4] = (byte)0;

tempMask[i * 4 + 2 + j * w * 4] = (byte)0;

}

else

{

tempMask[i * 4 + j * w * 4] = (byte)(temp[(i + x) * 4 + (j + y) * w * 4]);

tempMask[i * 4 + 1 + j * w * 4] = (byte)(temp[(i + x) * 4 + 1 + (j + y) * w * 4]);

tempMask[i * 4 + 2 + j * w * 4] = (byte)(temp[(i + x) * 4 + 2 + (j + y) * w * 4]);

tempMask[i * 4 + 3 + j * w * 4] = (byte)(temp[(i + x) * 4 + 3 + (j + y) * w * 4]);

}

}

}

Stream sTemp = translateImage.PixelBuffer.AsStream();

sTemp.Seek(0, SeekOrigin.Begin);

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

return translateImage;

}

else

{

returnnull;

}

}

[图像效果]

Win8Metro(C#)数字图像处理--2.18图像平移变换相关推荐

  1. Win8Metro(C#)数字图像处理--2.3图像反色

    原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下:     ...

  2. Win8Metro(C#)数字图像处理--2.7图像伪彩色

    Win8Metro(C#)数字图像处理--2.7图像伪彩色 原文:Win8Metro(C#)数字图像处理--2.7图像伪彩色  2.7图像伪彩色函数 [函数名称] 图像伪彩色函数PseudoCol ...

  3. Win8Metro(C#)数字图像处理--2.33图像非线性变换

    原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换  [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...

  4. Win8Metro(C#)数字图像处理--2.26图像减法

     [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBitmap subSrc) [算法说明] 图像减法就是将两幅图像对应 ...

  5. C语言数字图像处理进阶---18 图像形变滤镜

    图像形变滤镜 图像形变滤镜代表的是一类滤镜,这类滤镜的特点就是像素位置发生了形变,通过位置形变来达到某种特效,比如哈哈镜,鱼眼镜头特效等等. 本文给大家介绍四款形变滤镜:波浪形变滤镜(WaveFilt ...

  6. Win8Metro(C#)数字图像处理--2.32图像曝光算法

     [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureValue) [函数代码] /// <summary> // ...

  7. Win8Metro(C#)数字图像处理--2.17图像木刻效果

     [函数名称] 图像木刻效果函数WoodCutProcess(WriteableBitmap src) [函数代码] ///<summary> /// Wood cut process ...

  8. Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测

    原文:Win8Metro(C#)数字图像处理--2.14Prewitt 边缘检测  [函数名称] 图像Prewitt边缘检测函数PrewittEdgeProcess(WriteableBitmap ...

  9. Win8Metro(C#)数字图像处理--2.24二值图像闭运算

    原文:Win8Metro(C#)数字图像处理--2.24二值图像闭运算  [函数名称] 二值图像闭运算函数CloseOperateProcess(WriteableBitmap src) [算法说 ...

最新文章

  1. python 读取grib \grib2
  2. python3 函数签名简介 验证函数参数
  3. 差分能量分析介绍(四)
  4. 理解MySQL——复制(Replication)
  5. 即时通讯音视频开发(八):常见的实时语音通讯编码标准
  6. ITK:创建派生内核DerivativeKernel
  7. [leetcode]160.相交链表
  8. 如何使用命令行拿到SAP Kyma的Lambda Function明细
  9. 大话领域驱动设计——简介
  10. hibernate正向生成数据库表以及配置——Teacher.java
  11. Hadoop64位版本安装后遇到的警告处理
  12. 阿里女员工遭遇「杀猪盘」背后的思考
  13. Exchange日常管理之四:简化OWA的登录
  14. Linux设备开机卡主
  15. 小甲鱼python笔记_小甲鱼Python笔记(类)
  16. No package python27 available
  17. Win7电脑蓝屏代码大全
  18. 飞机大战(源码+素材)
  19. 计算机网络的高可用性和分布式处理
  20. 技术经理成长复盘-我是什么样的人

热门文章

  1. unity 学习记录
  2. 夺命雷公狗---微信开发09----玩转单图文消息回复
  3. thinkphp自动验证分析
  4. linux 隐藏显示终端光标
  5. SQL server 第三方驱动 JDTS
  6. UPPERERR.txt
  7. ASP.NET MVC源码现在可以下载了(翻译)
  8. 架构部署001---双机集群(HA)系统
  9. JAVA零碎要点014---java+selenium环境搭建_浏览器自动化测试框架
  10. JAVA学习笔记001---认识了解NIO