Re: XForms: Problem displaying images

T.C. Zhao (tc_zhao@yahoo.com)
Sat, 25 Sep 1999 08:50:59 -0700 (PDT)

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

Thank you for sending me the demo problem. At the moment,
I can't seem to reproduce the problem. Moving and redrawing
occur correctly. Maybe somewhere there is a race condition
that does not shown on my machine. I'll look into it a bit more.
BTW, my X server is 32bpp.

--- Ravi Mehrotra <ravi@csnpl.ren.nic.in> wrote:
> Dear T.C.,
>
> Thanks for the suggestion. I have tried it. The problem of the image
> loaded in the canvas graying out once the canvas is moved persists.
> I have written a small piece of code to test it out. I am sending as
> attachments the code as file image.c and the ppm image as median.ppm.
>
>
> Just to recap, I am using a Pentium II machine with Linux 2.2.6 and
> XForms 0.89 with a depth of 16bpp. I am displaying a ppm format image
> in
> a canvas. The canvas is moved and picture redisplayed through a
> canvas
> handler trapping the Expose event. Upon moving the canvas, the image
> grays outto a very faint one and loses all color. This does not
> happen
> if thewhole form is moved using the title bar of the window ( which
> also
> generates an Expose event). The problem occurs only on using depths
> greater than 8 bpp.
>
> I did some further tests. I used another version of Linux 2.0.30 on a
> Pentium Pro machine with XForms 0.88, Date: 1998/08/25. The problem
> disappeared. The program compiled on this machine and run on the
> earlier
> Pentium II machine also shows no problems. The program compiled
> under
> XForms 0.89 shows the problem on both computers. Thus it seems that
> the
> problem is in the 0.89 version.
>
> I will appreciate any further help.
>
> Ravi Mehrotra
> National Physical Laboratory
> New Delhi, India
>
>
>
>
> "T.C. Zhao" wrote:
> >
> > # 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.> #include "forms.h"
> #include <stdlib.h>
>
> FL_FORM *im;
>
> FL_OBJECT
> *canvas,
> *move;
>
> FL_IMAGE *pic;
>
> void move_cb(FL_OBJECT *ob, long data)
> {
> fl_set_object_position(canvas,canvas->x+50,canvas->y+50);
> }
>
> int handler(FL_OBJECT *ob, Window win, int w, int h, XEvent *xev,
> void *data)
> {
> if (xev->type==Expose)
> pic->display(pic,FL_ObjWin(canvas));
> }
>
>
>
> void create_form_im(void)
> {
> FL_OBJECT *obj;
>
> if (im)
> return;
>
> im = fl_bgn_form(FL_NO_BOX,390,360);
> obj = fl_add_box(FL_UP_BOX,0,0,390,360,"");
> canvas = obj = fl_add_canvas(FL_NORMAL_CANVAS,10,10,115,115,"");
> move = obj = fl_add_button(FL_NORMAL_BUTTON,130,310,120,40,"Move");
> fl_set_object_lsize(obj,FL_MEDIUM_SIZE);
> fl_set_object_lstyle(obj,FL_BOLD_STYLE);
> fl_set_object_callback(obj,move_cb,0);
> fl_end_form();
>
> }
>
> void create_the_forms(void)
> {
> create_form_im();
> }
>
>
> int main(int argc, char *argv[])
> {
> fl_initialize(&argc, argv, 0, 0, 0);
>
> create_the_forms();
> pic = flimage_alloc();
> pic = flimage_load("median.ppm");
> fl_add_canvas_handler(canvas,Expose,handler,NULL);
>
> fl_show_form(im,FL_PLACE_CENTER,FL_FULLBORDER,"im");
> fl_do_forms();
> return 0;
> }
>

> ATTACHMENT part 3 image/x-portable-pixmap name=median.ppm

__________________________________________________
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/