我需要保存bitmap
在byte[]
与C#,如何做到这一点?此如何在byte [] c#中保存位图?
2
A
回答
7
工作的代码是
System.Drawing.Image originalImage = dpgraphic.image;// replace your image here i.e image bitmap
//Create empty bitmap image of original size
float width=0, height=0;
Bitmap tempBmp = new Bitmap((int)width, (int)height);
Graphics g = Graphics.FromImage(tempBmp);
//draw the original image on tempBmp
g.DrawImage(originalImage, 0, 0, width, height);
//dispose originalImage and Graphics so the file is now free
g.Dispose();
originalImage.Dispose();
using (MemoryStream ms = new MemoryStream())
{
// Convert Image to byte[]
tempBmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
//dpgraphic.image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
byte[] imageBytes = ms.ToArray();
}
1
看看从MSDN http://msdn.microsoft.com/en-us/library/system.drawing.imaging.bitmapdata.aspx这个示例中,我希望你正在寻找这一点。
1
怎么样
在
YourByteArray = System.IO.File.ReadAllBytes("YourGraphic.bmp");
读写出来
System.IO.File.WriteAllBytes("SaveToFile.bmp", YourByteArray);
作品对我来说
相关问题
- 1. 如何在图库中保存位图?
- 2. 如何在c#应用程序设置中保存byte []
- 3. 如何将HTML保存为byte []作为图像??? c#
- 4. 如何在C++中声明byte *(byte array)?
- 5. C#保存位图输出
- 6. 保存位图图像,如C#
- 7. 如何保存位图
- 8. 在C#中的位置保存位图图像
- 9. C#将object []转换为byte [],但如何将字节对象保存为byte?
- 10. 在Android中保存位图
- 11. 如何使用程序保存byte []?
- 12. 如何将一个byte []保存为java.sql.Clob?
- 13. 如何保存到MFC C++应用程序中的位图?
- 14. 如何将图像保存为C#中的8位?
- 15. 如何将位图保存为图标?
- 16. 如何在SQL中保存一个Byte数组?
- 17. 在C中保存图形#
- 18. 问题与保存图像在C中的特定位置#
- 19. 如何将图形转换为位图并将其保存在c#中?
- 20. 如何在C#中将8位灰度图像转换为byte []数组?
- 21. 将32位位图保存为C#中的1位.bmp文件
- 22. C++位图保存二进制标志
- 23. 通过C#在WPF中保存位图图像
- 24. 保存用户在c#中绘制位图图形
- 25. 保存byte []数组到MYSQL
- 26. 如何在wp7中保存透明背景的位图图像
- 27. 如何从位图图像保存到存储在Android的
- 28. 如何在C/C++中保存数据?
- 29. 如何在Android中将位图保存到位图时设置dpi图像?
- 30. 保存位图时背景变黑 - C#
重复:http://stackoverflow.com/questions/268013/怎么办 - 我 - 转换 - 一个位图到字节 – Alex 2011-03-17 12:37:30