MagickSetImageAlpha Function

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
Flocke
Posts: 4
Joined: 2014-02-21T06:31:18-07:00
Authentication code: 6789

MagickSetImageAlpha Function

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

}
Flocke
Posts: 4
Joined: 2014-02-21T06:31:18-07:00
Authentication code: 6789

Re: MagickSetImageAlpha Function

Post 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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MagickSetImageAlpha Function

Post 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()
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply