Beispiel #1
0
void draw_pixmap(Widget w, XtPointer client_data, XtPointer call_data)
{
    GC gc; XGCValues vals;
    XpmImage *xpmImage = (XpmImage*) client_data;
//    Pixmap pixmap;
    XImage *image, *si;

    gc=XtGetGC(w, 0 ,&vals);


    XpmCreateImageFromXpmImage(XtDisplay(w), xpmImage, &image, &si, NULL);

    XPutImage(XtDisplay(w), XtWindow(w), gc, image, 0, 0, 0, 0,
              xpmImage->width, xpmImage->height);

    XDestroyImage(image);

//    XpmCreatePixmapFromXpmImage(XtDisplay(w), XtWindow(w),
//                                xpmImage, &pixmap, NULL, NULL);
//    XCopyArea(XtDisplay(w),pixmap,XtWindow(w), gc, 0, 0,
//              xpmImage->width, xpmImage->height, 0, 0);
//    XFreePixmap(XtDisplay(w),pixmap);

    XtReleaseGC(w, gc);

}
Beispiel #2
0
int
XpmCreateImageFromBuffer(Display *display, char *buffer, XImage **image_return,
			 XImage **shapeimage_return, XpmAttributes *attributes)
{
    XpmImage image;
    XpmInfo info;
    int ErrorStatus;

    /* create an XpmImage from the buffer */
    if (attributes) {
	xpmInitAttributes(attributes);
	xpmSetInfoMask(&info, attributes);
	ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, &info);
    } else
	ErrorStatus = XpmCreateXpmImageFromBuffer(buffer, &image, NULL);

    if (ErrorStatus != XpmSuccess)
	return (ErrorStatus);

    /* create the related ximages */
    ErrorStatus = XpmCreateImageFromXpmImage(display, &image,
					     image_return, shapeimage_return,
					     attributes);
    if (attributes) {
	if (ErrorStatus >= 0)		/* no fatal error */
	    xpmSetAttributes(attributes, &image, &info);
	XpmFreeXpmInfo(&info);
    }
    /* free the XpmImage */
    XpmFreeXpmImage(&image);

    return (ErrorStatus);
}