Page 1 of 1

MagickSetImageAlpha Function

Posted: 2014-02-21T06:40:53-07:00
by Flocke
Hey!

I want to set the transparecy of an image to a specific value (for example: 1.0 is opaqu and 0.0 is transparent). The documentation tells me that there is an "MagickSetImageAlpha" function, but it doesn't exist (anymore?).
I want to make a pattern transparent.
Heres my function im using right now to create a pattern and drawing it on a wand.
(this is just a little helper function the d_wand and the rest of the operation is in other parts of the file and works fine)

Greetings,
Flocke

Code: Select all

void set_tile_pattern(DrawingWand *d_wand,char *pattern_name,char *pattern_file)
{
	MagickWand *t_wand;
	long w,h;
	
	t_wand=NewMagickWand();  
	MagickReadImage(t_wand,pattern_file);
	MagickSetImageAlphaChannel(t_wand,ActivateAlphaChannel);  //SetAlphaChannel ???
      //MagickSetImageAlpha does not exist anymore
	w = MagickGetImageWidth(t_wand);
	h = MagickGetImageHeight(t_wand);

	DrawPushPattern(d_wand, pattern_name+1, 0, 0, w, h);
	DrawComposite(d_wand, SrcOverCompositeOp, 0, 0, 0, 0, t_wand);
	DrawPopPattern(d_wand);
	DrawSetFillPatternURL(d_wand, pattern_name);

}

Re: MagickSetImageAlpha Function

Posted: 2014-02-21T06:56:27-07:00
by Flocke
Well i was looking through the api and found the "MagickTransparentPaintImage" function...

Code: Select all

MagickBooleanType MagickTransparentPaintImage(MagickWand *wand,
    const PixelWand *target,const double alpha,const double fuzz,
    const MagickBooleanType invert)
"MagickTransparentPaintImage() changes any pixel that matches color with the color defined by fill."

With the fuzz set to 10000, and the PixelWand just initialised without any settings it's changing every pixel in my pattern to the tranparent i want... so this i somekind of a workaround i think. Seems to work so far.

But still, what's going on with the MagickSetImageAlpha function?

Re: MagickSetImageAlpha Function

Posted: 2014-07-20T20:53:54-07:00
by anthony
It was probably merged into a generalised 'Alpha' or 'Channel' function.

The way I find it is to follow the equivelent command line option. "alpha" in this case.

Hmmm for IMv6 it calls the Magick Library SetImageAlphaChannel()

The Wand function name appears to be MagickSetImageAlphaChannel()