從圖像轉換到byte[]數組的幾種方法
来源:互联网 发布:上交所数据 编辑:程序博客网 时间:2024/05/16 09:26
http://www.cnblogs.com/keyrratuff/archive/2009/02/11/1388009.html
// 性能最高,其數組和像素一一對應public static void test1(Image img) { Bitmap bmp = new Bitmap(img); BitmapData bitmapData = bmp.LockBits(new Rectangle(new Point(0, 0), img.Size), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb); byte[] BGRValues = new byte[bitmapData.Stride * bitmapData.Height]; IntPtr Ptr = bitmapData.Scan0; System.Runtime.InteropServices.Marshal.Copy(Ptr, BGRValues, 0, BGRValues.Length); bmp.UnlockBits(bitmapData); }// 性能較低,數組內容較少,內容未知 public static void test2(Image img) { System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter(); byte[] btImage1 = new byte[0]; btImage1 = (byte[])ic.ConvertTo(img, btImage1.GetType()); }// 性能較低,數組內容為圖片格式內容,格式未知 public static void test3(Image img) { System.IO.MemoryStream ms = new System.IO.MemoryStream(); img.Save(ms,ImageFormat.Bmp); byte[] byteImage = new Byte[0]; byteImage = ms.ToArray(); }
- 從圖像轉換到byte[]數組的幾種方法
- byte[]转hex的方法
- java short转byte的方法
- Byte数组转换成string 的方法
- byte 转无符号的方法
- object 转换成byte[] 的方法
- java short转byte的方法
- Java中byte转int的方法
- 【IO】InputStream的read(byte[] b)方法
- 将一个超出byte范围的值转为byte的方法
- android 将int转byte,byte转int的两种方法
- android 将int转byte,byte转int的两种方法
- opencv(java) byte[] 转换为Mat&Mat 转 byte[](用好Mat的get(),put()方法)
- java的对象-》jason-》String-》byte数组的转化方法。
- Byte[]和byte[]的转换
- IOS 方法返回Byte*
- 数据类型int跟byte[]数组互转的方法!
- java中把对象转化为byte数组的方法
- App列表之下拉刷新
- #pragam once 和 #ifndef 预编译头
- poj2478 法雷级数 递推法求欧拉函数
- App数据格式之解析Json
- Velocity能为你做什么?
- 從圖像轉換到byte[]數組的幾種方法
- 数组指针和指针数组
- 工業相機,工業攝像機,工業攝像頭的選擇
- javascript 去除空格
- 9月编程语言排行榜
- android 实现微信的开门效果
- SEO基础教程——meta标签
- 网络经济与企业管理--概论
- 书的复制 二分解法