Outputting 1 channel 16-bit grayscale PNG
Posted: 2011-10-11T08:44:59-07:00
I'm attempting to take uint16 data and output it as a 1024x768 1-channel 16-bit grayscale PNG. The output I get from the following is an RGB8 PNG. The image contents are correct besides the formatting.
Is there any way to specify more about the output format?
Some discussion of imagemagick's PNG handling is here: http://www.imagemagick.org/Usage/formats/#png_formats They list PNG8, PNG24, and PNG32 as available formats, but the following section implies that the following on the commandline would have the desired output.
How do I issue these define commands with the Magick++ api? Or in a safe way, calling to the plain ol c magick API?
Code: Select all
gray16_view_t u16view = ...;
uint16_t* data = interleaved_view_get_raw_data(u16view);
size_t length = sizeof(u16) * u16view.width() * u16view.height();
Magick::Blob u16Blob(data, length);
Magick::Geometry size(u16view.width(), u16view.height());
Magick::Image u16MagickImg(u16Blob, size, 16, "GRAY");
u16MagickImg.write("test-16bit.png");
Some discussion of imagemagick's PNG handling is here: http://www.imagemagick.org/Usage/formats/#png_formats They list PNG8, PNG24, and PNG32 as available formats, but the following section implies that the following on the commandline would have the desired output.
Code: Select all
-define png:bit-depth 16
-define png:color-type=0