adding alpha channel

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
glow
Posts: 3
Joined: 2012-07-07T16:58:05-07:00
Authentication code: 13

adding alpha channel

Post by glow » 2012-07-07T17:06:46-07:00

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

el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: adding alpha channel

Post by el_supremo » 2012-07-07T18:43:35-07:00

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
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.

glow
Posts: 3
Joined: 2012-07-07T16:58:05-07:00
Authentication code: 13

Re: adding alpha channel

Post by glow » 2012-07-08T04:32:14-07:00

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?

glow
Posts: 3
Joined: 2012-07-07T16:58:05-07:00
Authentication code: 13

Re: adding alpha channel

Post by glow » 2012-07-08T04:58:39-07:00

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);

Post Reply