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开发者_StackOverflow中文版 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.
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.
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.
精彩评论