XForms: Problems with flimage_add_text

From: David Scriven (davidwriter@yahoo.com)
Date: Mon Jan 14 2002 - 12:36:29 EST


# To subscribers of the xforms list from David Scriven <davidwriter@yahoo.com> :

I'm writing an image display routine. The image has multiple
planes and I have written a routine using FL_IMAGE as a
base. The image is displayed on a free form. I first set the
image thus:

// Setup image  
    bitmap = flimage_alloc();

    bitmap->type = FL_IMAGE_CI;
    bitmap->w = Xdim;
    bitmap->h = Ydim;
    bitmap->map_len=260;
    bitmap->ci_maxval=260;
    flimage_getmem(bitmap);
    // Create a mono bitmap
    for(int i = 0; i < 256; i++)
    {
        bitmap->red_lut[i] = i;
        bitmap->green_lut[i] = i;
        bitmap->blue_lut[i]  = i;
    }
    // other special colormap settings
   .....

The core of the display loop is the simple sequence:

void Play::ConvertImageToDisplay()
{
   ....
   Calculate bitmap values from lookup
   ...
   bitmap->modified = 1;
   flimage_sdisplay(bitmap, window);
}
This works perfectly and displays any plane on
command - however if I add the code

char planetxt[16];
sprintf(planetxt,"%d",planeno);
flimage_add_text(bitmap,planetxt,strlen(planetxt),FL_FIXED_STYLE,  
FL_NORMAL_SIZE, FL_PACK(255,0,0), 0, 1, 10.0, 10.0, 0);

before the bitmap->modified = 1 line
and add
flimage_delete_all_text(bitmap);
after the  flimage_sdisplay it crashes the SECOND time I enter
this section of code ie - it displays the number on the image the
first time, but when I try and show a different number (and plane),
it crashes.

When a do a debug I get the following error sequence:

(gdb) where
#0  0x4005d2db in XTextWidth () from /usr/X11R6/lib/libX11.so.6
#1  0x40188d3b in fl_drw_string () from /usr/lib/libforms.so.0.89
#2  0x40189753 in fl_draw_text_cursor () from /usr/lib/libforms.so.0.89
#3  0x40189b89 in fl_draw_text_inside () from /usr/lib/libforms.so.0.89
#4  0x40159593 in display_text () from /usr/lib/libforms.so.0.89
#5  0x4014b1ee in handle_redraw () from /usr/lib/libforms.so.0.89
#6  0x4014ba4a in flimage_sdisplay () from /usr/lib/libforms.so.0.89
#7  0x0804b5e0 in Play::ConvertImageToDisplay (this=0xbffff450)

I'm running ver 0.89-6  under Red Hat Linux 7.2 with XFree v 4.0.3 and using
the gcc v 2.96-85 compiler

I've tried flimage_add_text_struct with the same effect.
I thought that flimage_render_annotation might solve the
problem  but it caused the program to crash immediately
with an error in XPutImage().

I'd be grateful for advice.
 
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://world.std.com/~xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/



This archive was generated by hypermail 2b29 : Wed May 01 2002 - 13:54:13 EDT