Problems with rectangle

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
piotrpsz

Problems with rectangle

Post by piotrpsz »

Hi,

I'm using Magick++.
I trying to draw a rectangle, for example;
image.draw( Magick::DrawableRectangle( 10, 10, 80, 80 ) );

And I have a message:
Non-conforming drawing primitive definition `rectangle' @ magick/draw.c/DrawImage/3112

Why? Can anyone tell me why?

regards
piotr
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Problems with rectangle

Post by magick »

Grab the ImageMagick source distribution and compile Magick++/demo/piddle.cpp and Magick++/demo/shapes.cpp. They are good examples to use to get started with Magick++ drawing.
piotrpsz

Re: Problems with rectangle

Post by piotrpsz »

magick wrote:Grab the ImageMagick source distribution and compile Magick++/demo/piddle.cpp and Magick++/demo/shapes.cpp. They are good examples to use to get started with Magick++ drawing.
But in file piddle.cpp, you are drawing a rectangle with lines.
DrawableReclangle not exists more?

In documentation is fragment:
> To draw polygon shapes on the canvas, the Magick++ library provides a generic
> 'DrawablePolygon' class and a specialized classes to draw rectangles: 'DrawableRectangle'.

piotr
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Problems with rectangle

Post by magick »

The following works for us. We're using ImageMagick 6.5.3-4:

Code: Select all

#include <Magick++.h>
#include <string>
#include <iostream>

using namespace std;
using namespace Magick;

int main( int /*argc*/, char ** argv)
{
  // Initialize ImageMagick install location for Windows
  InitializeMagick(*argv);
  try {
    string srcdir("");
    if(getenv("SRCDIR") != 0)
      srcdir = getenv("SRCDIR");
    //
    // Create a 300x300 white canvas.
    //
    Image image( "300x300", "white" );
    image.draw(Magick::DrawableRectangle( 10, 10, 80, 80 ) );
    cout << "Writing image \"piddle_out.miff\" ..." << endl;
    image.compressType( RLECompression );
    image.write( "piddle_out.miff" );
    cout << "Writing MVG metafile \"piddle_out.mvg\" ..." << endl;
    image.write( "piddle_out.mvg" );
  }
  catch( exception &error_ )
    {
      cout << "Caught exception: " << error_.what() << endl;
      return 1;
    }
  return 0;
}
Post Reply