1a966c04fSmrg/* 2a966c04fSmrg * Copyright (C) 1989-95 GROUPE BULL 3a966c04fSmrg * 4a966c04fSmrg * Permission is hereby granted, free of charge, to any person obtaining a copy 5a966c04fSmrg * of this software and associated documentation files (the "Software"), to 6a966c04fSmrg * deal in the Software without restriction, including without limitation the 7a966c04fSmrg * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 8a966c04fSmrg * sell copies of the Software, and to permit persons to whom the Software is 9a966c04fSmrg * furnished to do so, subject to the following conditions: 10a966c04fSmrg * 11a966c04fSmrg * The above copyright notice and this permission notice shall be included in 12a966c04fSmrg * all copies or substantial portions of the Software. 13a966c04fSmrg * 14a966c04fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15a966c04fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16a966c04fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17a966c04fSmrg * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18a966c04fSmrg * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19a966c04fSmrg * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20a966c04fSmrg * 21a966c04fSmrg * Except as contained in this notice, the name of GROUPE BULL shall not be 22a966c04fSmrg * used in advertising or otherwise to promote the sale, use or other dealings 23a966c04fSmrg * in this Software without prior written authorization from GROUPE BULL. 24a966c04fSmrg */ 25a966c04fSmrg 26a966c04fSmrg/*****************************************************************************\ 27a966c04fSmrg* CrPFrData.c: * 28a966c04fSmrg* * 29a966c04fSmrg* XPM library * 30a966c04fSmrg* Parse an Xpm array and create the pixmap and possibly its mask * 31a966c04fSmrg* * 32a966c04fSmrg* Developed by Arnaud Le Hors * 33a966c04fSmrg\*****************************************************************************/ 34a966c04fSmrg 35a966c04fSmrg#ifdef HAVE_CONFIG_H 36a966c04fSmrg#include <config.h> 37a966c04fSmrg#endif 38a966c04fSmrg#include "XpmI.h" 39a966c04fSmrg 40a966c04fSmrgint 412e2dd055SmrgXpmCreatePixmapFromData( 422e2dd055Smrg Display *display, 432e2dd055Smrg Drawable d, 442e2dd055Smrg char **data, 452e2dd055Smrg Pixmap *pixmap_return, 462e2dd055Smrg Pixmap *shapemask_return, 472e2dd055Smrg XpmAttributes *attributes) 48a966c04fSmrg{ 4952dc082bSmrg XImage *ximage = NULL, *shapeimage = NULL; 50a966c04fSmrg int ErrorStatus; 51a966c04fSmrg 52a966c04fSmrg /* initialize return values */ 53a966c04fSmrg if (pixmap_return) 54a966c04fSmrg *pixmap_return = 0; 55a966c04fSmrg if (shapemask_return) 56a966c04fSmrg *shapemask_return = 0; 57a966c04fSmrg 58a966c04fSmrg /* create the images */ 59a966c04fSmrg ErrorStatus = XpmCreateImageFromData(display, data, 60a966c04fSmrg (pixmap_return ? &ximage : NULL), 61a966c04fSmrg (shapemask_return ? 62a966c04fSmrg &shapeimage : NULL), 63a966c04fSmrg attributes); 64a966c04fSmrg 65a966c04fSmrg if (ErrorStatus != XpmSuccess) 6652dc082bSmrg goto cleanup; 67a966c04fSmrg 68a966c04fSmrg /* create the pixmaps and destroy images */ 69a966c04fSmrg if (pixmap_return && ximage) { 7052dc082bSmrg ErrorStatus = 7152dc082bSmrg xpmCreatePixmapFromImage(display, d, ximage, pixmap_return); 7252dc082bSmrg if (ErrorStatus < 0) /* fatal error */ 7352dc082bSmrg goto cleanup; 74a966c04fSmrg } 75a966c04fSmrg if (shapemask_return && shapeimage) { 7652dc082bSmrg ErrorStatus = 7752dc082bSmrg xpmCreatePixmapFromImage(display, d, shapeimage, shapemask_return); 7852dc082bSmrg } 7952dc082bSmrg 8052dc082bSmrg cleanup: 8152dc082bSmrg if (ximage != NULL) 8252dc082bSmrg XDestroyImage(ximage); 8352dc082bSmrg if (shapeimage != NULL) 84a966c04fSmrg XDestroyImage(shapeimage); 8552dc082bSmrg if (ErrorStatus < 0) { 8652dc082bSmrg if (pixmap_return && *pixmap_return) { 8752dc082bSmrg XFreePixmap(display, *pixmap_return); 8852dc082bSmrg *pixmap_return = 0; 8952dc082bSmrg } 9052dc082bSmrg if (shapemask_return && *shapemask_return) { 9152dc082bSmrg XFreePixmap(display, *shapemask_return); 9252dc082bSmrg *shapemask_return = 0; 9352dc082bSmrg } 94a966c04fSmrg } 95a966c04fSmrg return (ErrorStatus); 96a966c04fSmrg} 97