c#载入图片,修改图片的二进制数据
2012-12-27 11:28
288 查看
上图片为rar合并图片,图片另存为后后缀改为rar,可以解压缩出项目。
private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Bitmap bitmap = new Bitmap("p.png");//如果用png图片,格式是rgb,如果用大小如240,240,格式是rgba BitmapData data = bitmap.LockBits(new Rectangle(0, 0, 200, 200), System.Drawing.Imaging.ImageLockMode.ReadWrite, bitmap.PixelFormat); IntPtr start = data.Scan0; // Declare an array to hold the bytes of the bitmap. int bytes = Math.Abs(data.Stride) * bitmap.Height; byte[] rgbValues = new byte[bytes]; // Copy the RGB values into the array. System.Runtime.InteropServices.Marshal.Copy(start, rgbValues, 0, bytes); // Set every third value to 255. A 24bpp bitmap will look red. for (int counter = 2; counter < rgbValues.Length; counter += 3) rgbValues[counter] = 255; // Copy the RGB values back to the bitmap System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, start, bytes); // Unlock the bits. bitmap.UnlockBits(data); g.DrawImage(bitmap, 0, 0, 200, 200); }
相关文章推荐
- c# 将图片的二进制数据插入到数据库中
- C#从数据库中读取二进制数据,并显示图片
- C#中图片转二进制到存储数据库
- C#中图片转二进制到存储数据库
- C# 二进制数据、图片存入、读出 sql server 数据库
- C#中利用ADO.NET存储图片、文件等二进制数据
- C# listView载入图片以大图标方式显示
- 关于把图片存入ACCESS形成二进制文件进行图片绑定显示(c#版)
- C#中datagridview获取当前行并修改数据
- ios sqlite中写入图片二进制数据及读取
- Atitit. 二进制数据ascii表示法,与base64编码解码api 设计标准化总结java php c#.net
- 在C#中将二进制数据转换成BASE64字符串的方法
- ASP.net(c#)将图片以二进制格式存储到数据库中
- 图片与二进制数据互转、图片数据转Base64
- 修改sql server 数据库字段报错:将截断字符串或二进制数据
- C# 将数据存为二进制数据文件
- C#对DataGridView中的数据进行添加、修改、删除操作
- C#中如何实现数据拖动?(拖动图片,到TextBox,并显示)
- c# 图片二进制存放
- C#+arcengine实现栅格计算器的减功能(可以用来修改栅格数据的高程)