Win8Metro(C#)数字图像处理--2.18图像平移变换
原文: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图像平移变换的更多相关文章
- Win8Metro(C#)数字图像处理--2.3图像反色
原文:Win8Metro(C#)数字图像处理--2.3图像反色 [函数名称] 图像反色函数ContraryProcess(WriteableBitmap src) [算法说明] 反色公式如下: ...
- Win8Metro(C#)数字图像处理--2.33图像非线性变换
原文:Win8Metro(C#)数字图像处理--2.33图像非线性变换 [函数名称] 图像非线性变换函数NonlinearTransformProcess(WriteableBitmap src ...
- Win8Metro(C#)数字图像处理--2.32图像曝光算法
原文:Win8Metro(C#)数字图像处理--2.32图像曝光算法 [函数名称] 图像曝光函数ExposureProcess(WriteableBitmap src,int exposureV ...
- Win8Metro(C#)数字图像处理--2.27图像加法运算
原文:Win8Metro(C#)数字图像处理--2.27图像加法运算 [函数名称] 图像加法函数AddProcess(WriteableBitmap src, WriteableBitmap a ...
- Win8Metro(C#)数字图像处理--2.28图像乘法运算
原文:Win8Metro(C#)数字图像处理--2.28图像乘法运算 [函数名称] 图像乘法函数MultiplicationProcess(WriteableBitmap src, Writea ...
- Win8Metro(C#)数字图像处理--2.29图像除法运算
原文:Win8Metro(C#)数字图像处理--2.29图像除法运算 [函数名称] 图像除法函数DivisionProcess(WriteableBitmap src, WriteableBit ...
- Win8Metro(C#)数字图像处理--2.26图像减法
原文:Win8Metro(C#)数字图像处理--2.26图像减法 [函数名称] 图像减法函数SubtractionProcess(WriteableBitmap src, WriteableBi ...
- Win8Metro(C#)数字图像处理--2.19图像水平镜像
原文:Win8Metro(C#)数字图像处理--2.19图像水平镜像 [函数名称] 图像水平镜像函数MirrorXProcess(WriteableBitmap src) [函数代码] ...
- Win8Metro(C#)数字图像处理--2.20图像垂直镜像
原文:Win8Metro(C#)数字图像处理--2.20图像垂直镜像 [函数名称] 图像垂直镜像函数MirrorYProcess(WriteableBitmap src) [函数代码] ...
随机推荐
- [React Router v4] Parse Query Parameters
React Router v4 ignores query parameters entirely. That means that it is up to you to parse them so ...
- 安全配置基线Linux系统
Linux系统安全配置基线 一:共享账号检查 配置名称:用户账号分配检查,避免共享账号存在 配置要求:1.系统需按照实际用户分配账号: 2.避免不同用户间共享账号,避免用户账号和服务器间通信使用的账号 ...
- 使用PowerDesigner15在win7下的系统MySQL p相反roject(一)
使用PowerDesigner15在win7下的系统MySQL 相反project 1.首先.安装下面的驱动 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv ...
- 关于hexo的SEO的好文章
1.hexo高阶教程:想让你的博客被更多的人在搜索引擎中搜到吗? 2.Hexo Seo优化让你的博客在google搜索排名第一 3.hexo 博客 seo 优化 4.HEXO SEO 高级优化 5.H ...
- Sublime Text3的react代码校验插件
之前写前端一直用的是jshint做语法检查,但jshint不支持JSX语法,为了在React使用,需要用eslint代替它.六月份的时候为了写React Native,编辑器换过Webstorm和VS ...
- Hibernate——(6)延迟加载机制
一.延迟加载机制的基本原理 当访问实体对象时,并不是立即到数据库中查找.而是在真正要使用实体对象的时候,才去数据库查询数据. 具备这样功能的方法 session.load(...) query.ite ...
- UWP 在 WebView 中执行 JavaScript 代码(用于模拟用户输入等) - walterlv
原文:UWP 在 WebView 中执行 JavaScript 代码(用于模拟用户输入等) - walterlv UWP 在 WebView 中执行 JavaScript 代码(用于模拟用户输入等) ...
- Qt实用技巧:使用QTableView、QSqlTableMode与QSqlDatabase对数据库数据进行操作
本文章博客地址:http://blog.csdn.net/qq21497936/article/details/78615800 Qt实用技巧:使用QTableView.QSqlTableMode与Q ...
- Using default security password
不展示Using default security password的解决办法: import org.springframework.context.annotation.Bean; import ...
- APP和服务端-架构设计(一)
架构因人而异,不同的架构师大多会有不同的看法:架构也因项目而异,不同的项目需求不同,相应的架构也会不同.然而,有些东西还是通用的,是所有架构师都需要考虑的,也是所有项目都会有的需求,比如API如何设计 ...