Page 1 of 1

Image::Display() shows DrawablePolygons incorrectly

Posted: 2019-06-19T06:35:24+00:00
by c2000e
Image::Display() turns all polygons into squares of varying size for some reason... when I actually write the image to a file, everything is as it should be with other types of polygons showing up.

I'm on version 7.0.8 of Magick++ on Arch Linux.

UPDATE: found out the squares are actually bounding boxes for the shapes, just had to draw the shapes in different colors to see it. Can't find anything in the docs to stop drawing the bounding box though so any help would be appreciated. Thanks!

UPDATE 2: the bounding boxes go away if the image's background color is completely transparent? however, the image keeps its background color so it works how I want it to now but not like it should it seems.

Code: Select all

int main()
{
	Magick::Image image(Magick::Geometry(640,480), Magick::Color(30, QuantumRange, QuantumRange, 0));
	std::cout << "hello" << std::endl;
	Magick::DrawablePolygon p1 = polygon(100.0, 100.0, 50.0, 7);
	Magick::DrawablePolygon p2 = polygon(200.0, 200.0, 40.0, 3);

	image.draw(p1);
	image.draw(p2);

	image.magick("png");
	image.write("maybeitllwork");

	image.display();

	return 0;
}

Magick::DrawablePolygon polygon(double x, double y, double radius, int npoints)
{
	Magick::CoordinateList points(npoints);

	float angle = 2 * M_PI / npoints;

	for (int i = 0; i < npoints; i++)
	{
		double sx = x + radius * cos(i * angle);
		double sy = y + radius * sin(i * angle);
		points[i] = (Magick::Coordinate(sx, sy));
	}
	
	return Magick::DrawablePolygon(points);
}