Reputation: 2809
I am using Freeimage.sf.net to load an png24bit and want to save it as black/white png. using
FIBITMAP bib = Freeimage.Load("<24bit_png>");
FIBITMAP conv = FreeImage.ConvertColorDepth(bib, FREE_IMAGE_COLOR_DEPTH. FICD_01_BPP_THRESHOLD, (byte) 128);
FreeImage.Unload(bin); bib.SetNull();
FreeImage.Save(FREE_IMAGE_FORMAT.FIF_PNG, conv, "<out_png>", FREE_IMAGE_SAVE_FLAGS.PNG_Z_BEST_COMPRESSION);
FreeImage.Unload(conv); conv.SetNull();
but the is not black/white, as it is #0b120c / white? why does the threshold not create a bw-palette?
Upvotes: 2
Views: 1363
Reputation: 25396
The line
FIBITMAP conv = FreeImage.ConvertColorDepth( bib,
FREE_IMAGE_COLOR_DEPTH.FICD_01_BPP_THRESHOLD, (byte) 128 );
builds a palette for the most used colors.
Replacing it with
FIBITMAP bw = FreeImage.Threshold( biRef, threshold_BW );
will create a truly black-and-white image.
Upvotes: 1