I'm trying to do what should be fairly simple: mask parts of an image
(using a greyscale mask - some parts could be masked out, others would
have varying levels of transparency based on the darkness of the mask)
and compose it on a background. The code below builds a mask and uses
CopyCompositeOp to set the alpha channel of the top layer, but the
resulting image is just the mask composed on the blue background rather
than a masked copy of the top image.
What's the proper series of function calls to get this done properly?
thx --
,----
| #include <wand/magick_wand.h>
|
| int
| main (void)
| {
| MagickWand *background;
| PixelWand *pw;
| MagickWand *img;
| MagickWand *mask;
| DrawingWand *dw;
| MagickBooleanType rc;
|
| MagickWandGenesis ();
|
| background = NewMagickWand ();
| pw = NewPixelWand ();
|
| rc = PixelSetColor (pw, "blue");
| rc = MagickNewImage (background, 640, 800, pw);
|
| img = NewMagickWand ();
|
| rc = MagickReadImage (img, "test-image.png");
|
| mask = NewMagickWand ();
|
| rc = PixelSetColor (pw, "gray");
| rc = MagickNewImage (mask, MagickGetImageWidth (img),
MagickGetImageHeight (img), pw);
|
| dw = NewDrawingWand ();
|
| rc = PixelSetColor (pw, "white");
| DrawSetFillColor (dw, pw);
| DrawRectangle (dw, 10.0, 10.0, 90.0, 90.0);
| rc = MagickDrawImage (mask, dw);
|
| DestroyDrawingWand (dw);
|
| rc = MagickCompositeImageChannel (img, AlphaChannel, mask,
CopyCompositeOp, 0, 0);
|
| DestroyMagickWand (mask);
|
| rc = MagickCompositeImage (background, img, OverCompositeOp, 40, 40);
|
| DestroyMagickWand (img);
|
| DestroyPixelWand (pw);
|
| MagickDisplayImage (background,":0");
|
| DestroyMagickWand (background);
|
| MagickWandTerminus();
|
| return 0;
| }
`----
--
Michael J. Barillier /// http://www.blackwolfinfosys.net/~blackwolf/
_O_| "... Ideas are bulletproof."
__O| -- V
OOO|
_______________________________________________
Magick-users mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-users