Re: XForms: Pixmaps, Bitmaps and Canvases (continued...)

Trent Piepho (xyzzy@u.washington.edu)
Thu, 12 Nov 1998 12:57:56 -0800 (PST)

# To subscribers of the xforms list from Trent Piepho <xyzzy@u.washington.edu> :

On Thu, 12 Nov 1998, Joao Filipe Ferreira wrote:
> The problem is I am trying to use XPutImage to transfer the data from a
> XImage-type variable, where the application had the portion of the
> original image stored earlier on, to the Pixmap variable and I can't seem
> to get it right - I fail to suply XPutImage with the right drawable ID.
>
> What should I do? I really would like to stick to my XORPositioner plan,
> since it is incredibly flexible and neat - just the thing I needed.

I do something like this for a program I wrote. This is the code that creates
the pixmap from some data I have, via an XImage. I then just use
fl_set_pixmap_pixmap() to to have the new pixmap displayed.

Pixmap datatopixmap()
{
int x,y;
XImage *i;
Pixmap p;
XWindowAttributes xwa;
unsigned char *data;
Window w=FL_ObjWin(Wp->Map2); /* window of Pixmap object */

XGetWindowAttributes(dpy, w, &xwa);

data=malloc(size_of_pixmap(xwa.depth));
p=XCreatePixmap(dpy, w, WIDTH, HEIGHT, xwa.depth);
i=XCreateImage(dpy, xwa.visual, xwa.depth, ZPixmap,
0, data, WIDTH, HEIGHT, 8, 0);

/* draw in the image */
for(x=0;x<WIDTH;x++) for(y=0;y<HEIGHT;y++) {
XPutPixel(i,x,y,fl_get_pixel(MapColors[station_map[y][x]]));
};

XPutImage(dpy, p, fl_state[fl_get_form_vclass(Wp->Wp)].gc[0],
i, 0,0, 0,0, WIDTH,HEIGHT);
XDestroyImage(i);

return p;
}

|Gazing up to the breeze of the heavens \ on a quest, meaning, reason |
|came to be, how it begun \ all alone in the family of the sun |
|curiosity teasing everyone \ on our home, third stone from the sun. |
|Trent Piepho (xyzzy@u.washington.edu) -- Metallica |

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuf2.usuhs.mil or see
http://bob.usuf2.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuf2.usuhs.mil/mailserv/list-archives/