gpt4 book ai didi

c# - 如何在 C# 中将 Color Lut 应用于位图图像

转载 作者:太空宇宙 更新时间:2023-11-03 16:57:56 27 4
gpt4 key购买 nike

我正在打开不同类型的图像,例如(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() 方法。

最佳答案

看一下位图的Image.Palette属性(property)。

关于c# - 如何在 C# 中将 Color Lut 应用于位图图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/797659/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com