简体   繁体   English

从真彩色图像转换为调色板颜色

[英]Converting from True Color Image to Palette Color

We have a .NET application which currently creates documents to TIFF files by printing to a virtual printer. 我们有一个.NET应用程序,该应用程序当前通过打印到虚拟打印机来创建TIFF文件的文档。 We would like to get rid of the virtual printer because it is expensive, slow, and does not support 64-bit operating systems. 我们希望摆脱虚拟打印机,因为它价格昂贵,速度慢且不支持64位操作系统。 Right now, I can use other tools at my disposal to create a TIFF image from, say, a Word document at 300 dpi. 现在,我可以使用其他工具根据300 dpi的Word文档来创建TIFF图像。 However, I don't have a great deal of control over the final TIFF format; 但是,我对最终的TIFF格式没有太多控制权; specifically, it creates full 24-bit true color images and thus very large TIFF files. 具体来说,它将创建完整的24位真彩色图像,从而生成非常大的TIFF文件。 The legacy solution, for all of its faults, does create nice 8-bit palette color TIFF files. 对于所有故障,传统解决方案均会创建漂亮的8位调色板颜色TIFF文件。

So my question is this: is there a straightforward, efficient way to convert a 24-bit, truecolor image to an 8-bit palette color image? 所以我的问题是:是否有一种直接,有效的方法将24位Truecolor图像转换为8位调色板彩色图像? It would be nice if the resulting palette was optimized for the particular image, but I realize that analyzing every pixel is probably too slow. 如果生成的调色板针对特定图像进行了优化,那将很好,但是我意识到分析每个像素可能太慢。 A solution that used a standard 8-bit palette would certainly be acceptable. 使用标准的8位调色板的解决方案当然可以接受。 Is there a method in the .NET imaging library that will do this, or a third-party, open source tool? .NET映像库中是否存在可以执行此操作的方法,还是第三方开放源代码工具? I've messed around a little with ImageMagick.NET, but was not very pleased with the experience. 我对ImageMagick.NET有点困惑,但是对这种体验并不满意。

If you save in .gif format, it should use a 256 color palette image. 如果以.gif格式保存,则应使用256色调色板图像。 That may be an easy solution if your client can read .gif files. 如果您的客户端可以读取.gif文件,那可能是一个简单的解决方案。 Leadtools can save paletized .tif files, but it's not open source. Leadtools可以保存已赋色的.tif文件,但它不是开源的。

Check out FreeImage . FreeImage There's a bunch of save flags that you can pass where you can specify compression levels. 您可以传递许多保存标志 ,以指定压缩级别。 There's also a method called ConvertColorDepth that sounds promising. 还有一种叫做ConvertColorDepth的方法听起来很有希望。 You'll have to look over the license to see if it fits you. 您必须查看许可证,看它是否适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM