Exemple #1
0
int
XpmWriteFileFromImage(
    Display		*display,
    char		*filename,
    XImage		*image,
    XImage		*shapeimage,
    XpmAttributes	*attributes)
{
    XpmImage xpmimage;
    XpmInfo info;
    int ErrorStatus;

    /* create an XpmImage from the image */
    ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
                  &xpmimage, attributes);
    if (ErrorStatus != XpmSuccess)
        return (ErrorStatus);

    /* write the file from the XpmImage */
    if (attributes) {
        xpmSetInfo(&info, attributes);
        ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, &info);
    } else
        ErrorStatus = XpmWriteFileFromXpmImage(filename, &xpmimage, NULL);

    /* free the XpmImage */
    XpmFreeXpmImage(&xpmimage);

    return (ErrorStatus);
}
int
XpmCreateBufferFromImage(
    Display		 *display,
    char		**buffer_return,
    XImage		 *image,
    XImage		 *shapeimage,
    XpmAttributes	 *attributes)
{
    XpmImage xpmimage;
    XpmInfo info;
    int ErrorStatus;

    /* initialize return value */
    if (buffer_return)
	*buffer_return = NULL;

    /* create an XpmImage from the image */
    ErrorStatus = XpmCreateXpmImageFromImage(display, image, shapeimage,
					     &xpmimage, attributes);
    if (ErrorStatus != XpmSuccess)
	return (ErrorStatus);

    /* create the buffer from the XpmImage */
    if (attributes) {
	xpmSetInfo(&info, attributes);
	ErrorStatus =
	    XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, &info);
    } else
	ErrorStatus =
	    XpmCreateBufferFromXpmImage(buffer_return, &xpmimage, NULL);

    /* free the XpmImage */
    XpmFreeXpmImage(&xpmimage);

    return (ErrorStatus);
}