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

标签 c# imaging

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

相关文章:

c# - 如何在 Xamarin Shell 中自定义顶部选项卡 (ShellSection) 的外观?

python - 将图像调整为给定边界区域的最简单方法是什么?

python - 如何使用 PIL(python 成像)创建透明 gif(或 png)

.net - 使用索引像素格式将文本写入图像

c# - 使用 linq 分组后查找平均时间和最大时间

c# - 从任何版本加载程序集

c# - 使用 DateTime.TryParse 方法检查有效日期

linux - 用于成像 Linux 应用程序的最佳语言/框架

.net - 如何将字节数组转换为位图实例 (.NET)?

c# - 从MainWindow访问类的实例