XForms: flimage_display() problem

From: gluck (gluck@vtx.ch)
Date: Sat Aug 19 2000 - 08:30:14 EDT

  • Next message: Steve Lamont: "Re: XForms: flimage_display() problem"

    # To subscribers of the xforms list from gluck <gluck@vtx.ch> :

    Hi,

    I'm using xforms 0.89 and its facilities for image creation.
    I have the following problem: when I draw an image and display it
    several times, it works only the first time.
    I know that I must do a img->modified = 1 to invalidate the buffer
    image. But it doesn't work....

    Any idea ??

    Thanks in advance.

        Flo

    Here is my complete code that display a red image and then a green one
    (doesn't work, only the red one is displayed!) :

    --------------------------------------------------------------------
    #include <forms.h>

    typedef unsigned char uchar;

    #define APPNAME "myapp"
    #define WIDTH 256
    #define HEIGHT 256

    void draw_image(FL_IMAGE *img, uchar r, uchar g, uchar b)
    {
     int i, j;

     for (j = 0; j < img->h; j++) {
      for (i = 0; i < img->w; i++) {
       img->packed[j][i] = FL_PACK(r,g,b);
      }
     }

     img->modified = 1;
    }

    int main(int argc, char **argv)
    {
     FL_FORM *form;
     FL_IMAGE *img;
     FL_OBJECT *canvas;

     fl_initialize(&argc, argv, APPNAME, 0, 0);
     form = fl_bgn_form(FL_FLAT_BOX, WIDTH, HEIGHT);
     canvas = fl_add_canvas(FL_NORMAL_CANVAS, 0, 0, WIDTH, HEIGHT,
    "mycanvas");
     fl_set_object_boxtype(canvas, FL_FLAT_BOX);
     fl_end_form();

     fl_show_form(form, FL_PLACE_MOUSE, FL_FULLBORDER, APPNAME);

     // create and alloc memory for the image
     img = flimage_alloc();
     img->type = FL_IMAGE_PACKED;
     img->w = WIDTH;
     img->h = HEIGHT;
     flimage_getmem(img);

     // draw & display the image (red)
     draw_image(img, 255,0,0);
     flimage_display(img, FL_ObjWin(canvas));

     // redraw & redisplay the image (blue)
     draw_image(img, 0,0,255);
     flimage_display(img, FL_ObjWin(canvas));

     fl_do_forms();

     return 0;
    }
    --------------------------------------------------------------------

    _________________________________________________
    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 : Sat Aug 19 2000 - 08:40:11 EDT