今天遇到一个问题:
图像数据存在一个byte[] grayBmp 里面,为8为灰度图像,不知怎么去构造一个bmp?
byte[] grayBmp = new byte[OtherStride * imgHeight];
fixed (byte* grayAddr = grayBmp)
{
IntPtr ptr = (IntPtr)grayAddr;
Bitmap bmp = new Bitmap(OtherStride, imgHeight,OtherStride,PixelFormat.Format8bppIndexed,ptr);
bmp.Save(fileName, ImageFormat.Bmp);
} 不知为何出来的都是一副8位彩色图像?不胜感激!
图像数据存在一个byte[] grayBmp 里面,为8为灰度图像,不知怎么去构造一个bmp?
byte[] grayBmp = new byte[OtherStride * imgHeight];
fixed (byte* grayAddr = grayBmp)
{
IntPtr ptr = (IntPtr)grayAddr;
Bitmap bmp = new Bitmap(OtherStride, imgHeight,OtherStride,PixelFormat.Format8bppIndexed,ptr);
bmp.Save(fileName, ImageFormat.Bmp);
} 不知为何出来的都是一副8位彩色图像?不胜感激!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货