问题 1。 我自己的相关问题
我在这里问了下一个问题
现在第二个问题是。
当我尝试从原始像素数据中打开 16 位(Monocrome)图像时,我收到错误消息。因为我在创建 Bitmap 时使用 PixelFormat.Format16bppGrayscale
Bitmap bmp = new Bitmap(Img_Width, Img_Height,PixelFormat.Format16bppGrayscale);
所以用谷歌搜索并发现不支持 Format16bppGrayscale 所以我修改了我的代码,如下所示。
PixelFormat format = PixelFormat.Format16bppRgb565;
Bitmap bmp = new Bitmap(Img_Width, Img_Height, format);
Rectangle rect = new Rectangle(0, 0, Img_Width, Img_Height);
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, format);
Marshal.Copy(rawPixel, 0, bmpData.Scan0, rawPixel.Length);
bmp.UnlockBits(bmpData);
令人惊奇的是,我现在正在获取图像,因为我更改了 pixelFormat。但问题是我的单色(灰度)图像看起来有各种颜色。
我怎样才能得到原来的样子。我尝试了几种灰度方法但不成功请给我一些不安全的代码。谢谢,