从真彩色图像转换为调色板颜色
我们有一个 .NET 应用程序,当前通过打印到虚拟打印机将文档创建为 TIFF 文件。我们希望摆脱虚拟打印机,因为它昂贵、缓慢且不支持 64 位操作系统。现在,我可以使用我可以使用的其他工具从 300 dpi 的 Word 文档中创建 TIFF 图像。然而,我对最终的 TIFF 格式没有太多的控制权;具体来说,它创建完整的 24 位真彩色图像,从而创建非常大的 TIFF 文件。传统解决方案尽管存在所有缺陷,但确实可以创建漂亮的 8 位调色板颜色 TIFF 文件。
所以我的问题是:是否有一种简单、有效的方法将 24 位真彩色图像转换为 8 位调色板彩色图像?如果生成的调色板针对特定图像进行了优化,那就太好了,但我意识到分析每个像素可能太慢了。使用标准 8 位调色板的解决方案当然是可以接受的。 .NET 映像库中是否有可以执行此操作的方法,或者第三方开源工具?我对 ImageMagick.NET 进行了一些尝试,但对这次体验不是很满意。
We have a .NET application which currently creates documents to TIFF files by printing to a virtual printer. We would like to get rid of the virtual printer because it is expensive, slow, and does not support 64-bit operating systems. Right now, I can use other tools at my disposal to create a TIFF image from, say, a Word document at 300 dpi. However, I don't have a great deal of control over the final TIFF format; specifically, it creates full 24-bit true color images and thus very large TIFF files. The legacy solution, for all of its faults, does create nice 8-bit palette color TIFF files.
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? 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. Is there a method in the .NET imaging library that will do this, or a third-party, open source tool? I've messed around a little with ImageMagick.NET, but was not very pleased with the experience.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果保存为 .gif 格式,则应使用 256 色调色板图像。如果您的客户可以读取 .gif 文件,这可能是一个简单的解决方案。 Leadtools 可以保存调色板.tif 文件,但它不是开源的。
If you save in .gif format, it should use a 256 color palette image. That may be an easy solution if your client can read .gif files. Leadtools can save paletized .tif files, but it's not open source.
查看 FreeImage。您可以传递一堆保存标志,您可以在其中指定压缩级别。还有一种名为 ConvertColorDepth 的方法听起来很有希望。您必须查看许可证,看看它是否适合您。
Check out 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. You'll have to look over the license to see if it fits you.