Page 1 of 1

PixelSetColor, gradient and DrawSetFillColor problem.

Posted: 2010-06-04T14:43:00-07:00
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!

Re: PixelSetColor, gradient and DrawSetFillColor problem.

Posted: 2010-06-05T13:02:01-07:00
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

Re: PixelSetColor, gradient and DrawSetFillColor problem.

Posted: 2010-06-06T09:49:14-07:00
by pinkfish00
that was my workaround as well, too bad this doesn't work ... thx.