---
name: "XpmCreateImageFromXpmImage"
section: "3"
platform: "linux"
package: "libxpm"
version: "3.5.20-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/XpmCreateImage"
---

# XpmCreateImageFromXpmImage(3)

create an XImage from an XPM

Part of [XpmCreateImage(3)](/XpmCreateImage/3.md).

## NAME

XpmCreateImage - create an XImage from an XPM

## SYNOPSIS

```
int XpmCreateImageFromData(Display *display, char **data,
XImage **image_return, XImage **shapeimage_return,
XpmAttributes *attributes);
int XpmCreateImageFromBuffer(Display *display, char *buffer,
XImage **image_return, XImage **shapeimage_return,
XpmAttributes *attributes);
int XpmCreateImageFromXpmImage(Display *display,  XpmImage *image,
XImage *image_return, XImage *shapeimage_return,
XpmAttributes *attributes);
```

## ARGUMENTS

- *display*

  Specifies the connection to the X server.

- *data*

  Specifies the location of the data.

- *image\_return*

  Returns the image which is created.

- *shapeimage\_return*

  Returns the shape mask image which is created if the color None is used.

- *attributes*

  Specifies the location of a structure to get and store information (or NULL).

- *shapeimage*

  Specifies the shape mask image which is created if any.

## DESCRIPTION

### XpmCreateImageFromData

To create an XImage from an XPM data, use **XpmCreateImageFromData**().

The **XpmCreateImageFromData**() function allows you to include in your C program an XPM file which was written out by functions such as [**XpmWriteFileFromImage**(3)](/XpmWriteFileFromImage/3.md) or [**XpmWriteFileFromPixmap**(3)](/XpmWriteFileFromPixmap/3.md) without reading in the file. **XpmCreateImageFromData**() exactly works as [**XpmReadFileToImage**(3)](/XpmReadFileToImage/3.md) does and returns the same way. It just reads data instead of a file. Here again, it is the caller’s responsibility to free the returned images, the colors, and possibly the data returned into the XpmAttributes structure.

### XpmCreateImageFromBuffer

To create an XImage from an XPM buffer, use **XpmCreateImageFromBuffer**(). The **XpmCreateImageFromBuffer**() function works the same way as [**XpmReadFileToImage**(3)](/XpmReadFileToImage/3.md), it just parses the buffer instead of the file. Be aware that the feature provided on some systems by [**XpmReadFileToImage**(3)](/XpmReadFileToImage/3.md) to deal with compressed files is not available here.

### XpmCreateImageFromXpmImage

To create an XImage from an XpmImage, use **XpmCreateImageFromXpmImage**(). From the given XpmImage and XpmAttributes if not NULL, **XpmCreateImageFromXpmImage**() allocates colors and creates X images following the same mechanism as [**XpmReadFileToImage**(3)](/XpmReadFileToImage/3.md). When finished the caller must free the images using [**XDestroyImage**(3)](/XDestroyImage/3.md), the colors using [**XFreeColors**(3)](/XFreeColors/3.md), and possibly the data returned into the XpmAttributes using [**XpmFreeAttributes**(3)](/XpmFreeAttributes/3.md).

## SEE ALSO

[**XpmFreeAttributes**(3)](/XpmFreeAttributes/3.md), [**XpmReadFileToImage**(3)](/XpmReadFileToImage/3.md)
