Problem with annotate and drawing text functions

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Problem with annotate and drawing text functions

Post by spok »

Hi,
I'm new with ImageMagick++.
I'm using it with Visual Studio 2008 (C++) and Windows 7 64 bits.
I have successed to compile it and to integrate it inside my application.
I have tried some functions such as drawing a rectangle or a circle inside an image and it worked.
However when I try to add a text it doesn't work. I have tried the draw method and the annotate method and both don't work.
The program runs normally but it just doesn't add anything to the image.
There are some behaviours that are very strange :
. when I use the draw method, the program crashes if I don't use first the font(<font name>) method of the Image class. I though it was enough to just use a DrawableFont object.
. if I use the following command in the command shell "convert -font Arial -fill blue -draw "text 10,10 'mytext here'" test.jpg result.jpg" then it works

I have tried the examples given in the tutorial but it doesn't work :-(

Any idea ? Thanks.
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Problem with annotate and drawing text functions

Post by spok »

Here is an example of the code I used. The texts are not displayed while the rectangle is displayed.
I have also tried the following for the font name without success : @arial.ttf, @c:\\windows\\font\\arial.ttf, helvetica.
Please help.

Code: Select all

Image monimage("test.jpg");

// Draw a text with annotate
monimage.font("@Arial");
monimage.boxColor("red");
monimage.backgroundColor("white");
monimage.fontPointsize( 72);
monimage.strokeColor("black");
monimage.fillColor( "gold" );
monimage.annotate( "Text Sample with annotate", NorthGravity );

// Draw a text with draw
monimage.draw(DrawableFont("@Arial"));
monimage.draw(DrawableStrokeColor("black"));
monimage.draw(DrawableFillColor(Color(0, 0, 0, MaxRGB)));
monimage.draw(DrawableTextUnderColor("white"));
monimage.draw(DrawableText(150,150,"Text Sample with draw"));

// Draw a rectangle
monimage.draw( Magick::DrawableRectangle(200,200, 270,170) );

monimage.write("resultat.jpg");
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Problem with annotate and drawing text functions

Post by spok »

no idea please ?
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Problem with annotate and drawing text functions

Post by spok »

I finally found the problem...
I needed to specify the full path for the font file.

Code: Select all

monimage.font("@c:\\windows\\fonts\\Arial.ttf");
spok
Posts: 36
Joined: 2011-10-31T07:32:23-07:00
Authentication code: 8675308

Re: Problem with annotate and drawing text functions

Post by spok »

I have to precise that when I used the full path name the first time, I haven't used the fillcolor function.
That's what it didn't work.
Using both makes the text appear.
Post Reply