Page 1 of 1

Trouble creating PNG with alpha in Magick++

Posted: 2010-07-15T15:03:29-07:00
by Icetigris
Hi, I need to process an image into two 16-bit per channel RGBA pngs, but for some reason I can't edit the alpha channel. I tried doing this just to see if it would work:

Code: Select all

	size_t columns = normalMap.columns(); size_t rows = normalMap.rows();
	Color blar(0.0, UINT_MAX, 0.0, UINT_MAX);
	PixelPacket *pixels = view.get(0,0,normalMap.columns(),normalMap.rows());
	for ( ssize_t row = 0; row < rows ; ++row )
	{
	 for ( ssize_t column = 0; column < columns ; ++column )
	 {
		 blar= *pixels;
		 Color other(blar.redQuantum() / 2, blar.greenQuantum() /2, blar.blueQuantum() / 2, 0);
		 *pixels++=other; 
	 }
	}
I'm doing this to save my image:

Code: Select all

normalMap.magick("PNG64");
	normalMap.write("test.png");
It saves out an image with fine color channels, but the alpha channel is all fully opaque. Any idea what I'm doing wrong or how to save out a png with an alpha channel? Thanks.

Re: Trouble creating PNG64 with alpha in Magick++

Posted: 2010-07-15T19:57:42-07:00
by fmw42
normalMap.magick("PNG64");
I am not a programmer or user of APIs, just command line IM, but I don't think IM can write a PNG64 whatever that is?

see http://www.imagemagick.org/Usage/formats/#png_formats

Re: Trouble creating PNG64 with alpha in Magick++

Posted: 2010-07-16T11:38:14-07:00
by Icetigris
Well it runs and makes an image fine with both PNG and PNG64 in there, just without any changes to the alpha. I need 16-bits per channel. Does Image.matte() being false tell anybody anything? Is there something I need to set so that I can get to the alpha channel?

Re: Trouble creating PNG with alpha in Magick++

Posted: 2010-07-16T12:05:07-07:00
by fmw42
Does Image.matte() being false tell anybody anything?
As I mentioned before, I do not use the APIs, but in command line if matte is off (+matte), then you have disabled the alpha channel.

If you are in IM Q16, then your produced png images will be 16 bits per channel. To create 8bits per channel then you would have to change the depth to 8. If you are in Q8 IM, then you cannot get 16-bits per channel as IM will only produce 8-bit images at best.

Re: Trouble creating PNG with alpha in Magick++

Posted: 2010-07-16T12:39:07-07:00
by Icetigris
I do have the 16-bit version. I didn't modify matte myself, I'm just reading in an image and then trying write out images with alpha. How do I set matte to true?

Re: Trouble creating PNG with alpha in Magick++

Posted: 2010-07-16T14:09:15-07:00
by Icetigris
Oh I think I found the problem. I was setting the images' types to TrueColorType instead of TrueColorMatteType. Now I can change the alpha channel.

Re: Trouble creating PNG with alpha in Magick++

Posted: 2010-07-18T20:59:38-07:00
by anthony
TrueColorMatte will have the effect of turning on Alpha.