Next: Using Markers, Up: Image Annotation [Contents][Index]
To place text into the image, use the following routine
int flimage_add_text(FL_IMAGE *im, const char *str, int len,
int fstyle, int fsize, unsigned tcolor,
unsigned bcolor, int nobk, double tx,
double ty, int rotation);
where fstyle and fsize are the same as the label font
style and size defined earlier in Section 3.11.3. tcolor and
bcolor specify the colors to use for the text str and
the background if the nobk argument is false. If nobk is
true the text is drawn without a background. tx and ty
specify the location of the text relative to the image origin. The
location specified is the lower-right corner of the text. Note that
the location specified can be in some physical space other than pixel
space. For example, if the pixel-pixel distance represents 10 miles on
a map, you’d like to be able to specify the text location in miles
rather than pixels. The location is converted into pixel space using
the following code
tx_pixel = im->xdist_scale * tx + im->xdist_offset;
ty_pixel = im->ydist_scale * ty + im->ydist_offset;
By default, the offsets im->xdist_offset and
im->yxdist_offset are initialized to 0 and the scales
im->xdist_scale and im->ydist_scale to 1.
The function returns the current number of strings for the image. The
interpretation of text used also used elsewhere applies, i.e., if
str starts with character @ a symbol is drawn.
There is another function, maybe more convenient depending on the application, that you can use
int flimage_add_text_struct(FL_IMAGE *im,
const FLIMAGE_TEXT *text);
With this function instead of passing all the parameters individual;y
you pass a FLIMAGE_TEXT structure to the function. The
structure has the following fields:
strThe string to append to the image.
lenLength of the string in bytes.
x, yA location relative to the image origin, given in pixels (no conversion from other coordinate systems is done)
alignSpecifies the alignment of the string relative to the give location.
style, sizeThe font style and size to use.
colorThe text color
bcolorThe background color
nobkIf true indicates that no background is to be drawn.
angleAngle (in thenth of a degree) the text is to be rotated from the default horizontal orientation. Currently only PostScript output handles this correctly.
To delete the all texts you added to an image, use
void flimage_delete_all_text(FL_IMAGE *im);
You also can suppress the display of annotation text without deleting
it. To do this, simply set im->dont_display_text to true.
Next: Using Markers, Up: Image Annotation [Contents][Index]