Page 1 of 1

Problem with annotate and drawing text functions

Posted: 2011-10-31T07:52:17-07:00
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.

Re: Problem with annotate and drawing text functions

Posted: 2011-11-01T06:06:57-07:00
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");

Re: Problem with annotate and drawing text functions

Posted: 2011-11-12T00:34:40-07:00
by spok
no idea please ?

Re: Problem with annotate and drawing text functions

Posted: 2011-11-12T17:26:02-07:00
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");

Re: Problem with annotate and drawing text functions

Posted: 2011-11-12T23:30:59-07:00
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.