PixelSetColor, gradient and DrawSetFillColor problem.

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
pinkfish00

PixelSetColor, gradient and DrawSetFillColor problem.

Post by pinkfish00 »

I have a question I hope somebody can help me.
I am using the C API, and I want to simply draw a rounded rectangle with a gradient fill.
Solid fill works great, but when I try to use a gradient, the rectangle is simply black, is this supported at all (I did not find any mention of the word 'gradient' in "pixel-wand.c")?
and if not what is the alternative?

Code: Select all

PixelSetColor(gradient, "gradient:red-blue"); // fails, full black
//PixelSetColor(gradient, "white"); // works, full white
DrawSetFillColor(draw, gradient);
DrawSetStrokeColor(draw, black);
DrawRoundRectangle(draw, 0, 0 ,inWidth-1, inHeight-1, 8, 8);
thank you!
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: PixelSetColor, gradient and DrawSetFillColor problem.

Post by el_supremo »

PixelSetColor returns a value of MagickFalse when given 'gradient:red-blue" as an argument.
The only alternative way to do it that I can think of is to create a rectangular gradient image of the appropriate size (using "gradient:red-blue" as an argument to MagickReadImage), create a plain white/black image with the rounded rectangle and use that as the alpha channel. Then composite this over the image. It's messy but should work.

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.
pinkfish00

Re: PixelSetColor, gradient and DrawSetFillColor problem.

Post by pinkfish00 »

that was my workaround as well, too bad this doesn't work ... thx.
Post Reply