What is the right way to use GradientImage?

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
gribuser
Posts: 2
Joined: 2019-12-03T01:08:10-07:00
Authentication code: 1152

What is the right way to use GradientImage?

Post by gribuser » 2019-12-04T14:46:41-07:00

I know that there is read("radial-gradient:#202020FF-#00000000") hack, and I know I can import some internal private headers to do some hacking over the MagicWand to inject something somewhere and get it over with (and forget asap).
But may be there is a sane, conventional way to do the trick? That's what I do now (it is not working as you would expect it to, it draws circles):

Code: Select all

	Magick::Image ObjectPict({ ObjectSizeX, ObjectSizeX }, BaseColor);
	
	MagickCore::_StopInfo* GradientStops = new MagickCore::_StopInfo[3];
	GradientStops[0].color = Magick::Color("#202020FF");
	GradientStops[0].offset = 0;

	GradientStops[1].color = Magick::Color("#101010FF");
	GradientStops[1].offset = ObjectSizeX / 3;

	GradientStops[2].color = Magick::Color("#000000FF");
	GradientStops[2].offset = ObjectSizeX;

	MagickCore::GradientImage(ObjectPict.image(), MagickCore::RadialGradient, MagickCore::PadSpread, GradientStops, 3, nullptr);

snibgo
Posts: 12400
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: What is the right way to use GradientImage?

Post by snibgo » 2019-12-04T16:11:55-07:00

"offset" should be in the range 0.0 to 1.0.
snibgo's IM pages: im.snibgo.com

gribuser
Posts: 2
Joined: 2019-12-03T01:08:10-07:00
Authentication code: 1152

Re: What is the right way to use GradientImage?

Post by gribuser » 2019-12-04T20:27:35-07:00

Yeah, that works, thanks.

Post Reply