当前位置: 首页 > news >正文

需要企业网站开发免费建设网站平台

需要企业网站开发,免费建设网站平台,纯静态网站 后台,杨浦网站建设公司方法一:直接修改RGB的值 首先将BitmapData扫描线上的所有像素复制到字节数组中,然后遍历数组并对每个像素的RGB值进行修改,最后将修改后的像素值复制回BitmapData。这个过程不会影响原始的Bitmap对象,但会改变锁定的位图区域的数…

方法一:直接修改RGB的值

首先将BitmapData扫描线上的所有像素复制到字节数组中,然后遍历数组并对每个像素的RGB值进行修改,最后将修改后的像素值复制回BitmapData。这个过程不会影响原始的Bitmap对象,但会改变锁定的位图区域的数据。当完成修改后,应调用UnlockBits()方法释放锁定的位图区域。
 

System.Drawing.Bitmap bitBufferRGB = new System.Drawing.Bitmap("彩色Bitmap图像.jpg");
System.Drawing.Imaging.BitmapData data = bitBufferRGB.LockBits(
new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitBufferRGB.Size),
System.Drawing.Imaging.ImageLockMode.ReadWrite, bitBufferRGB.PixelFormat);//获取内存
IntPtr pData = data.Scan0;
int bytes = data.Stride * bitBufferRGB.Height;
byte[] rgbValues = new byte[bytes];// Copy the RGB values into the array.
System.Runtime.InteropServices.Marshal.Copy(pData, rgbValues, 0, bytes);for (int y = 0; y < bitBufferRGB.Height; y++)
{for (int x = 0; x < bitBufferRGB.Width; x++){// 获取像素(x, y)在数组中的索引。int index = y * data.Stride + x * 3;// 修改RGB值。rgbValues[index] = (byte)(rgbValues[index] * 0.9); // 修改红色分量rgbValues[index + 1] = (byte)(rgbValues[index + 1] * 0.7); // 修改绿色分量rgbValues[index + 2] = (byte)(rgbValues[index + 2] * 0.9); // 修改蓝色分量}
}// Copy the modified RGB values back to the bitmap.
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, pData, bytes);//解锁及释放资源
bitBufferRGB.UnlockBits(data);
bitBufferRGB.Dispose();

方法二:更换RGB的值位置

更换R和B的位置

System.Drawing.Bitmap bitBufferRGB = new System.Drawing.Bitmap("彩色Bitmap图像.jpg");
System.Drawing.Imaging.BitmapData data = bitBufferRGB.LockBits(
new System.Drawing.Rectangle(System.Drawing.Point.Empty, bitBufferRGB.Size),
System.Drawing.Imaging.ImageLockMode.ReadWrite, bitBufferRGB.PixelFormat);//获取内存
IntPtr pData = data.Scan0;
int bytes = data.Stride * bitBufferRGB.Height;
byte[] rgbValues = new byte[bytes];
System.Runtime.InteropServices.Marshal.Copy(pData, rgbValues, 0, bytes);for (int i = 0; i < height; i++)
{for (int ji = 0; ji < width; ji++){int index = i * width + ji;// 每个像素占用三个字节// 红色字节rgbValues[index * 3] = System.Runtime.InteropServices.Marshal.ReadByte(pData, index * 3 + 2);// 绿色字节rgbValues[index * 3 + 1] = System.Runtime.InteropServices.Marshal.ReadByte(pData, index * 3 + 1);// 蓝色字节rgbValues[index * 3 + 2] = System.Runtime.InteropServices.Marshal.ReadByte(pData, index * 3);}
}
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, pData, bytes);//解锁及释放资源
bitBufferRGB.UnlockBits(data);
bitBufferRGB.Dispose();

 

 

 

 

 

http://www.mmbaike.com/news/72251.html

相关文章:

  • 惠州技术支持网站建设谷歌搜索排名规则
  • 网站建设类东莞企业网站排名
  • c 网站开发需要学什么注册一个域名需要多少钱
  • 做app还要做网站么网络营销论文5000字
  • 烟台产品网站建设西安疫情最新通知
  • wordpress做网站好吗seo体系
  • WordPress开通用户投稿功能上海牛巨微seo
  • 网站快照更新慢项目推广渠道有哪些
  • 微信小程序制作需要什么基础百度seo排名软
  • 网站推广营销公司推广普通话手抄报文字内容
  • 兼职做网站设计软文营销经典案例200字
  • 重庆网站制作合作商北京竞价托管代运营
  • 南宁百度网站公司电话百度账号购买网站
  • 做网站全自动cpa引流北京seo技术
  • 网站建设工具品牌有今日头条关键词排名优化
  • 青岛做网站如何用html制作网页
  • 网站建设实习困难百度热搜榜排名今日第一
  • html5网站制作教程湖南做网站的公司
  • 生活信息网站如何推广杭州seo百度关键词排名推广
  • 网站不想续费百度文库登录入口
  • 建英语网站好seo建设
  • dsicuz做的网站移投界seo
  • 自己电脑做网站访问快吗如何做一个自己的网站呢
  • 邵阳做网站公司站长权重
  • 企业微信开通流程网站seo报价
  • 网站建设合同.doc百度seo优化招聘
  • 姑苏区住房和建设局网站seo网站推广优化
  • 百度做网站要多长时间高端网站建设深圳
  • 扬州做网站公司引流推广
  • 临朐门户网站关于软文营销的案例