我正在打开不同类型的图像,例如(8 位和 16 位),它们是(单色、RGB、调色板颜色)。
我有这些图像的原始像素数据。我为 8 位图像创建这样的位图。
//for monocrome images i am passing PixelFormat.Format8bppIndexed.
//for RGB images i am passing PixelFormat.Format24bppRgb
PixelFormat format = PixelFormat.Format8bppIndexed;
Bitmap bmp = new Bitmap(Img_Width, Img_Height,format);
Rectangle rect = new Rectangle(0, 0, Img_Width, Img_Height);
//locking the bitmap on memory
BitmapData bmpData = bmp.LockBits(rect, ImageLockMode.ReadWrite, format);
// copy the managed byte array to the bitmap's image data
Marshal.Copy(rawPixel, 0, bmpData.Scan0, rawPixel.Length);
bmp.UnlockBits(bmpData);
问题是,当我绘制该 bmp 图像时,它的颜色与原始图像不同。那么有什么方法可以在彩色图像上应用 lut(查找表)。
我想要任何不安全的代码,因为我尝试了 getixel 和 setPixel 并且它们非常慢。我也不想要 Image.fromSource() 方法。