| 1 |
/* Copyright 1990,91 GROUPE BULL -- See licence conditions in file COPYRIGHT */ |
| 2 |
/*****************************************************************************\ |
| 3 |
* XpmRdFToP.c: * |
| 4 |
* * |
| 5 |
* XPM library * |
| 6 |
* Parse an XPM file and create the pixmap and possibly its mask * |
| 7 |
* * |
| 8 |
* Developed by Arnaud Le Hors * |
| 9 |
|
| 10 |
051116 last modif |
| 11 |
\*****************************************************************************/ |
| 12 |
|
| 13 |
#include "xpmP.h" |
| 14 |
|
| 15 |
int |
| 16 |
XpmReadFileToPixmap(display, d, filename, pixmap_return, |
| 17 |
shapemask_return, attributes) |
| 18 |
Display *display; |
| 19 |
Drawable d; |
| 20 |
char *filename; |
| 21 |
Pixmap *pixmap_return; |
| 22 |
Pixmap *shapemask_return; |
| 23 |
XpmAttributes *attributes; |
| 24 |
{ |
| 25 |
XImage *image, **imageptr = NULL; |
| 26 |
XImage *shapeimage, **shapeimageptr = NULL; |
| 27 |
int ErrorStatus; |
| 28 |
XGCValues gcv; |
| 29 |
GC gc; |
| 30 |
|
| 31 |
/* |
| 32 |
* initialize return values |
| 33 |
*/ |
| 34 |
if (pixmap_return) { |
| 35 |
*pixmap_return = 0; /* was: pixmap_return = NULL; */ |
| 36 |
imageptr = ℑ |
| 37 |
} |
| 38 |
if (shapemask_return) { |
| 39 |
*shapemask_return = 0; /* was: *shapemask_return = NULL */ |
| 40 |
shapeimageptr = &shapeimage; |
| 41 |
} |
| 42 |
|
| 43 |
/* |
| 44 |
* create the images |
| 45 |
*/ |
| 46 |
ErrorStatus = XpmReadFileToImage(display, filename, imageptr, |
| 47 |
shapeimageptr, attributes); |
| 48 |
if (ErrorStatus < 0) |
| 49 |
return (ErrorStatus); |
| 50 |
|
| 51 |
/* |
| 52 |
* create the pixmaps |
| 53 |
*/ |
| 54 |
if (imageptr && image) { |
| 55 |
*pixmap_return = XCreatePixmap(display, d, image->width, |
| 56 |
image->height, image->depth); |
| 57 |
gcv.function = GXcopy; |
| 58 |
gc = XCreateGC(display, *pixmap_return, GCFunction, &gcv); |
| 59 |
|
| 60 |
XPutImage(display, *pixmap_return, gc, image, 0, 0, 0, 0, |
| 61 |
image->width, image->height); |
| 62 |
|
| 63 |
XDestroyImage(image); |
| 64 |
XFreeGC(display, gc); |
| 65 |
} |
| 66 |
if (shapeimageptr && shapeimage) { |
| 67 |
*shapemask_return = XCreatePixmap(display, d, shapeimage->width, |
| 68 |
shapeimage->height, |
| 69 |
shapeimage->depth); |
| 70 |
gcv.function = GXcopy; |
| 71 |
gc = XCreateGC(display, *shapemask_return, GCFunction, &gcv); |
| 72 |
|
| 73 |
XPutImage(display, *shapemask_return, gc, shapeimage, 0, 0, 0, 0, |
| 74 |
shapeimage->width, shapeimage->height); |
| 75 |
|
| 76 |
XDestroyImage(shapeimage); |
| 77 |
XFreeGC(display, gc); |
| 78 |
} |
| 79 |
return (ErrorStatus); |
| 80 |
} |