Page 1 of 1

adding alpha channel

Posted: 2012-07-07T17:06:46-07:00
by glow
Hey Guys,

i started working with magick++ and i have a problem. I open a png file and like to make it transparent.
but everything i tried is not working:

Code: Select all

Image baseImage; //create base image 
baseImage.read("./img/desert.png"); //read file

//stuff i tried
baseImage.magick( "RGBA" );
baseImage.matte( "TRUE" );
baseImage.opacity(50);

cloneBaseImage.write(fileName); //safe file
can someone help me? how can i add an alpha channel to my image?

cheers
glow

Re: adding alpha channel

Posted: 2012-07-07T18:43:35-07:00
by el_supremo
This is a fragment of some code I wrote in C which uses MagickWand. It creates a blank 6000x1000 image and then turns on the alpha channel. Perhaps you can find the equivalent of MagickSetImageAlphaChannel in Magick++.

Code: Select all

	mw = NewMagickWand();
	MagickSetSize(mw,6000,1000);

	MagickReadImage(mw,"xc:none");
	// -alpha on
	MagickSetImageAlphaChannel(mw,SetAlphaChannel);
Pete

Re: adding alpha channel

Posted: 2012-07-08T04:32:14-07:00
by glow
i cant find anything which set an alpha channel in magick++.
the only thing which comes near is image.matte("TRUE").
description from the docu is: True if the image has transparency. If set True, store matte channel if the image has one otherwise create an opaque one.

but this has no effect. also creating a canvas and setting it to "RGBA" and then compositing my image inside has no effect.
any ideas?

Re: adding alpha channel

Posted: 2012-07-08T04:58:39-07:00
by glow
when i set opacity like this to fully transparent it seems to work. i get a completely transparent png:

Code: Select all

cloneBaseImage.opacity(TransparentOpacity);
but when i use it with an integer value i get a fully opaque image:

Code: Select all

cloneBaseImage.opacity(50);