I was using the FreeImageNET libary to Quantize my Bitmap as
我使用FreeImageNET libary来量化我的位图。
using (FreeImageAPI.FreeImageBitmap fiBitmap = FreeImageAPI.FreeImageBitmap.FromHbitmap(bmp.GetHbitmap()))
{
if (fiBitmap.ColorDepth > 24)
{
fiBitmap.ConvertColorDepth(FreeImageAPI.FREE_IMAGE_COLOR_DEPTH.FICD_08_BPP);
}
//quantize using the NeuQuant neural-net quantization algorithm
fiBitmap.Quantize(FreeImageAPI.FREE_IMAGE_QUANTIZE.FIQ_NNQUANT, 256);
fiBitmap.Save("test_z.png", FreeImageAPI.FREE_IMAGE_FORMAT.FIF_PNG, FreeImageAPI.FREE_IMAGE_SAVE_FLAGS.PNG_Z_BEST_COMPRESSION);
//fiBitmap.Save(ms, FreeImageAPI.FREE_IMAGE_FORMAT.FIF_PNG, FreeImageAPI.FREE_IMAGE_SAVE_FLAGS.PNG_Z_DEFAULT_COMPRESSION);
}
This gives me a PNG-8, with a palette of 256 colors. Using Photoshop I found, I could further reduce the size if I used Adaptive Algorithm with reduced color palette say 128, 64, 16 etc. Reopening it again shows Photoshop fills in grey levels in those remaining(higher) indexes.
这给了我一个PNG-8,带有256色的调色板。使用Photoshop我发现,如果我使用自适应算法,我可以进一步缩小尺寸,比如128、64、16等。重新打开后,Photoshop在剩下的(更高的)索引中填充了灰度。
I cannot get FreeImageAPI.FreeImageBitmap.Quantize()
to churn out a similar PNG, with limited palette, a la PIL convert()
where you can specify both the algorithm and the palette size.
我无法获得FreeImageAPI.FreeImageBitmap.Quantize()来产生一个类似的PNG,使用有限的调色板,一个la PIL convert(),在那里你可以指定算法和调色板的大小。
Thanks.
谢谢。
1 个解决方案
#1
1
Ended up re-implementing quantization by using open-source codes from the Internet.
最后,通过使用来自互联网的开源代码来重新实现量化。
#1
1
Ended up re-implementing quantization by using open-source codes from the Internet.
最后,通过使用来自互联网的开源代码来重新实现量化。