我成功地从他们的原始像素数据中绘制了图像。(只有 8 位图像)。这是做同样事情的代码。
PixelFormat format = PixelFormat.Format8bppIndexed;
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);
现在众所周知,c# 2.0 GDI+ 不支持 PixelFormat.format16bppGrayscale。我用谷歌搜索并获得了 3.0/3.5 框架支持。所以我两个都安装了。支持的类是 System.windows.media.PixelFormats。PixelFormats.Gray16
现在我的问题是如何通过传递此参数来创建位图并获取要显示的图像。
我在那里得到了一些 BitmapSource 类,但我在 C#3.0 中很新。
请帮我。