Draw image and GTK

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
pomsel

Draw image and GTK

Post by pomsel »

Hello,

if i use Image draw() after gtk_init() it failed with
terminate called after throwing an instance of 'Magick::ErrorDraw'
what(): ImageMagick: Non-conforming drawing primitive definition `rectangle'
Before gtk_init Drawable works perfect.

Thanks for any help!

Code: Select all

#include "gtk/gtk.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "Magick++.h"

using namespace std;
using namespace Magick;
void testbild()
{
	Image image5( "400x400", "white" );
	image5.strokeColor("red");
	image5.fillColor("green");
	image5.strokeWidth(5);
	image5.draw(DrawableRectangle(200,200, 100,100));
	image5.display( );
}

int main(int argc, char **argv)
{
	testbild(); // OK
	gtk_init (NULL, NULL);
	testbild();  // failure
	return 0;
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Draw image and GTK

Post by magick »

We cannot reproduce the problem you posted. We're using ImageMagick 6.6.5-7 and your program displays a rectangle on a white background twice than exits without complaint.
pomsel

Re: Draw image and GTK

Post by pomsel »

Thanks for your quick reply.
I have new installed Magick and GTK and now it works.
After add StrokeOpacity it stop with:
terminate called after throwing an instance of 'Magick::ErrorDraw'
what(): Magick: non-conforming drawing primitive definition `,' @ error/draw.c/DrawImage/3146
after gtk_init().

Code: Select all

#include "gtk/gtk.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "Magick++.h"

using namespace std;
using namespace Magick;
void testbild()
{
   Image image5( "400x400", "white" );
   std::list<Magick::Drawable> drawList;
   drawList.push_back(DrawableStrokeColor("red"));
   drawList.push_back(DrawableFillColor("green"));
   drawList.push_back(DrawableStrokeWidth(10));
   drawList.push_back(DrawableRectangle(200,200, 100,100));
   drawList.push_back(DrawableStrokeColor("yellow"));
   drawList.push_back(DrawableStrokeOpacity(0.2));
   drawList.push_back(DrawableRectangle(50,50, 180,180));
   image5.draw(drawList);
   image5.display( );
}

int main(int argc, char **argv)
{
   testbild(); // OK
   gtk_init (NULL, NULL);
   testbild();  // failure
   return 0;
}
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Draw image and GTK

Post by magick »

We cannot reproduce the problem you posted. We're using ImageMagick 6.6.5-7 and your program displays a green bordered rectangle on top of a red bordered rectangle on a white background twice than exits without complaint.
Post Reply