Re: XForms: Problem displaying images

T.C. Zhao (tc_zhao@yahoo.com)
Sat, 18 Sep 1999 10:08:41 -0700 (PDT)

# To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :

--- Ravi Mehrotra <ravi@csnpl.ren.nic.in> wrote:
> # To subscribers of the xforms list from Ravi Mehrotra
> <ravi@csnpl.ren.nic.in> :
>
> Hi,
>
> I am using XForms version 0.89 on a Linux 2.2.6 Pentium II machine.
> I have a True color image with depth 16. I use the following code to
> display the image in a canvas.
>
> void load_cb(FL_OBJECT *ob, long data)
> {
> FL_IMAGE *pic;
>
> pic=flimage_alloc();
lose the above statement. Call flimage_alloc() only if
you're creating image with raw data.

> pic=flimage_load("picture.ppm");
> pic->display(pic, FL_ObjWin(canvas));
> XFlush(fl_display);
> sleep(1);
> fl_set_object_position(canvas,canvas->x+50,canvas->y+50);
> pic->display(pic, FL_ObjWin(canvas));
> XFlush(fl_display);
> }

This is basically a programming error. When you call set_position,
it'll generate an Expose event on the canvas, which may or may
not get delivered or handled by the time you call pic->display again.
If you can't see the image after second pic->display() call,
it's most likely that it gets wiped by the default canvas Expose
handler, which just refreshes the canvas. To correctly handle this
kind of situation,
always install a canvas expose handler, and lose the second display
call.
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com
_________________________________________________
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://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/