关于图像处理的方法(内存法)

youdiving 2012-07-21 04:18:02
if(curBitmap !=null)
{
Rectangle rect = new Rectangle(0,0,curBitmap.Width,curBitmap.Height);
BitmapData bmpdata = curBitmap.LockBits(rect, ImageLockMode.ReadWrite,curBitmap.PixelFormat);
IntPtr ptr = bmpdata.Scan0;
int bytes = curBitmap.Width * curBitmap.Height * 3;
byte [] rgbValues=new byte [bytes];
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
double colorTemp = 0;
for (int i = 0; i < rgbValues.Length;i=i+3 )
{
colorTemp = rgbValues[i + 2] * 0.299 + rgbValues[i + 1] * 0.587 + rgbValues[i] * 0.114;//为什么不是是rgbvalues[i]*0.299+rgbvalues[i+1]*0.587+rgbvalues[i+2]*0.114
rgbValues[i] = rgbValues[i + 1] = rgbValues[i + 2] = (byte)colorTemp;
}
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);
curBitmap.UnlockBits(bmpdata);
Invalidate();
}
...全文
177 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
youdiving 2012-07-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]
像素在内存里是B、G、R顺序保存的。。
[/Quote]
thank you!!!
zhoujk 2012-07-21
  • 打赏
  • 举报
回复
你到我的资源去下载一个类,关于图像读写的
足球中国 2012-07-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 的回复:]

像素在内存里是B、G、R顺序保存的。。
[/Quote]
bmp一直都是这样存储。jpg四个量也是分别存储的。
bdmh 2012-07-21
  • 打赏
  • 举报
回复
你去问作者什么意图,他应该是对各个点的color进行调整,要一种效果
Conmajia 2012-07-21
  • 打赏
  • 举报
回复
像素在内存里是B、G、R顺序保存的。。

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧