I'm writing a PNG importer for my program, which
internally uses a 32-bit ARGB container for bitmaps.
I use something similar to sBIT to keep track of the
actual alpha/color precision. I also would like to
detect if the bitmap is actually grayscale (in which
case I only use the B component).
I use conveniently use png_set_gray_to_rgb to
import a grayscale PNG to my 32-bit ARGB bitmap.
When writing the ARGB bitmap to a PNG file, I'd like
to use a similar method, ignoring the G and B
components, or using png_set_gray_to_rgb to mix
them.
Logged In: YES
user_id=24402
If you just want to transform your RGB image to grayscale,
there is already a function called png_set_rgb_to_gray().
If you want a lossless RGB-to-Gray, palette-to-Gray,
alpha-strip etc. reduction, then you can use the code in
"opngreduc.c" from OptiPNG. That code *might* become a part
of libpng in the future, if the maintainer of libpng will
agree.
You may find OptiPNG at
http://www.cs.toronto.edu/~cosmin/pngtech/optipng/
I hope this helps.
Cosmin Truta