I need to read the palette and pixel indices from an indexed PNG with RGBA pixels.
Can I use Magick::Image to retrieve this information?
Thanks.
Read Palettized RGBA PNG
Re: Read Palettized RGBA PNG
Yes, see http://www.imagemagick.org/Magick++/ and look for a discussion of pixel iterators.
Re: Read Palettized RGBA PNG
I found this page on pixel iterator but cant see how it can be used.
http://www.imagemagick.org/api/pixel-iterator.php
Can you please provide short code snippet here?
Thanks.
http://www.imagemagick.org/api/pixel-iterator.php
Can you please provide short code snippet here?
Thanks.
Re: Read Palettized RGBA PNG
Did you review this page: http://www.imagemagick.org/Magick++/Pixels.html?
Re: Read Palettized RGBA PNG
Yes, but I couldn't see how to retrieve the color palette !?magick wrote:Did you review this page: http://www.imagemagick.org/Magick++/Pixels.html?
I had tried the following code using Image. But the color returned by img.colorMap() has opacity=0 irrespective of the palette index sampled.
Code: Select all
Magick::Image img;
img.read(fileName.c_str());
Magick::IndexPacket *ip = img.getIndexes();
if(ip)
{
int clrMapSz = img.colorMapSize();
Magick::Color clr = img.colorMap(10);
}
Re: Read Palettized RGBA PNG
Not sure what you're looking for. The getConst() method returns the pixel red, green, blue, and opacity and the indexes() method returns the colormap indexes and the colorMap() method returns the red, green, blue of each colormap entry.
Re: Read Palettized RGBA PNG
I'm writing a utility that will save decoded PNG to a custom file format. This file will then be used to load compressed (palette + indices) texture into OpenGL.
So I need to read the palette entires RGBA (alpha is required) and the pixel indices from the PNG file and dump this information in an uncompressed form to a binary file.
I can use getConstPixels to retrieve the pixel opacity values and add this to the RGB returned by colorMap. Is there a better way to directly get the complete palette information (RGB + A) ?
Thanks.
So I need to read the palette entires RGBA (alpha is required) and the pixel indices from the PNG file and dump this information in an uncompressed form to a binary file.
I can use getConstPixels to retrieve the pixel opacity values and add this to the RGB returned by colorMap. Is there a better way to directly get the complete palette information (RGB + A) ?
Thanks.