XpmWrite(3)
π XpmWrite β writing your XPMs to disk, bestie π
okay so this is XpmWrite from libXpm, section 3 of the manual. it's the whole little family of functions that take your pixmaps, images, buffers and data arrays and β¨*write them out*β¨ as XPM files. no cap, it's giving "export button" energy. let's get into it π«Ά
β¨ SYNOPSIS β¨
int XpmWriteFileFromPixmap(Display *display, char *filename,
Pixmap pixmap, Pixmap shapemask, XpmAttributes *attributes);
int XpmWriteFileFromImage(Display *display , char *filename,
XImage *image, XImage *shapeimage, XpmAttributes *attributes);
int XpmWriteFileFromData(char *filename, char **data);
int XpmWriteFileFromXpmImage(char *filename, XpmImage *image,
XImage *shapeimage, XpmInfo *info);
int XpmWriteFileFromBuffer(char *filename, char *buffer);
πΈ ARGUMENTS πΈ
displayβ the connection to the X server, literally just the plug into your X session πfilenameβ the file name to use. yes, that one. the name of the file. πpixmapβ the pixmap. she's the star of the show πshapemaskβ the shape mask pixmap, aka the little silhouette that says which bits are actually visible πattributesβ where a structure full of information lives (orNULL, if you're feeling minimal) β¨dataβ the data array to read πimageβ the image πΌοΈinfoβ where a structure to get information from lives (orNULL) πbufferβ the buffer to read π§Ί
π DESCRIPTION π
π¦ XpmWriteFileFromImage
XpmWriteFileFromImage() writes an image and its possible shapeimage out to a file in the XPM format. iconic behaviour honestly.
if the file cannot be opened, it returns XpmOpenFailed π. if insufficient working storage is allocated, it returns XpmNoMemory π. if no error occurs then it returns XpmSuccess π.
if the passed XpmAttributes structure pointer is not NULL, XpmWriteFileFromImage() goes looking for these attributes:
XpmColormapXpmHotspotXpmCharsPerPixelXpmRgbFilenameXpmExtensions
and as a backward compatibility feature, XpmWriteFileFromImage() also looks for the XpmInfos attributes. the more you know π
if the filename contains an extension such as β.xpmβ, in order to get a valid C variable name, the dot character is replaced by an underscore '_' when writing out. yes bestie, the dot gets glow-upped into an underscore, it's a whole transformation β¨
as a backward compatibility feature, if the XpmInfos attributes are defined it writes out possible stored information such as comments, color defaults and symbol. π
finally, if the XpmRgbFilename attribute is defined, XpmWriteFileFromImage() searches for color names in this file and if found writes them out instead of the rgb values. so fancy π¨
in addition, on systems which support such features: if the given file name ends by'.Z'or'.gz'it is assumed to be a compressed file. thenXpmWriteFileFromImage()writes to a pipedcompressorgzipprocess. and if instead of a file name,NULLis passed toXpmWriteFileFromImage(), it writes to the standard output. the way that it just pipes itself, no cap π₯
π§ XpmWriteFileFromPixmap
to write out a Pixmap to an XPM file, use XpmWriteFileFromPixmap(). simple as that π
if the passed XpmAttributes structure pointer is not NULL, XpmWriteFileFromPixmap() looks for the following attribute: XpmSize. if it's not defined, it performs an XGetGeometry operation. then it uses XGetImage to get from the given pixmaps the related X images which are passed to XpmWriteFileFromImage(). finally XpmWriteFileFromPixmap() destroys the created images using XDestroyImage. clean up after yourself, periodt π§Ή
the XpmWriteFileFromPixmap() function returns the same errors as XpmWriteFileFromImage().
π XpmWriteFileFromData
XpmWriteFileFromData() writes an XPM data array to an XPM file.
XpmWriteFileToData() returns XpmOpenFailed if it cannot open the file, XpmFileInvalid if this is not a valid XPM data, and XpmSuccess otherwise.
π XpmWriteFileFromXpmImage
to write out an XpmImage to an XPM file, use XpmWriteFileFromXpmImage(). the XpmWriteFileFromXpmImage() function writes an image out to a file in the XPM format.
if the file cannot be opened, it returns XpmOpenFailed π. if insufficient working storage is allocated, it returns XpmNoMemory π. if no error occurs then it returns XpmSuccess π.
if the passed XpmInfo structure pointer is not NULL, XpmWriteFileFromXpmImage() looks for these attributes:
XpmCommentsXpmExtensionsXpmHotspot
and writes the related information out as well π.
in addition, on systems which support such features: if the given file name ends by '.Z' or '.gz' it is assumed to be a compressed file. then XpmWriteFileFromXpmImage() writes to a piped compress or gzip process. and if instead of a file name, NULL is passed to XpmWriteFileFromXpmImage(), it writes to the standard output π
π XpmWriteFileFromBuffer
XpmWriteFileFromBuffer() writes a XPM buffer to a file. XpmWriteFileFromBuffer() returns XpmOpenFailed if it cannot open the file, and XpmSuccess otherwise.
as a convenience, the XpmReadFileToBuffer() and XpmWriteFileFromBuffer() functions are provided to copy a file to a buffer and to write a file from a buffer. thus for instance one may decide to use XpmCreateBufferFromPixmap(), XpmWriteFileFromBuffer(), and XpmFree() instead of XpmWriteFileFromPixmap(). on some systems this may lead to a performance improvement, since the parsing will be performed in memory, but it uses more memory. highkey a tradeoff, you gotta pick your vibe βοΈ
π SEE ALSO π
that's the whole thing bestie, you're officially an XPM-writing main character now π
β¨ go forth and write those files. this was X Version 11, libXpm 3.5.17, from the XpmWrite(3) page β ily, bye π«ΆππΈ
π¦ where this page comes from
- centos-stream 10: libXpm-devel 3.5.17-5.el10 Β· MIT AND X11-distribute-modifications-variant
- debian trixie: libxpm-dev 1:3.5.17-1+deb13u1
- fedora 43: libXpm-devel 3.5.17-6.fc43 Β· MIT AND X11-distribute-modifications-variant
- fedora 43: libXpm-devel 3.5.17-6.fc43 Β· MIT AND X11-distribute-modifications-variant
- fedora 44: libXpm-devel 3.5.17-7.fc44 Β· MIT AND X11-distribute-modifications-variant
- fedora 44: libXpm-devel 3.5.17-7.fc44 Β· MIT AND X11-distribute-modifications-variant
- opensuse-leap 16.0: libXpm-devel 3.5.17-160000.4.1 Β· MIT
- opensuse-leap 16.0: libXpm-devel 3.5.17-160000.4.1 Β· MIT
- opensuse-leap 16.0: libXpm-devel 3.5.17-160000.4.1 Β· MIT
- opensuse-leap 16.0: libXpm-devel 3.5.17-160000.4.1 Β· MIT
- ubuntu noble: libxpm-dev 1:3.5.17-1build2
- ubuntu noble: libxpm-dev 1:3.5.17-1ubuntu0.24.04.2
- ubuntu questing: libxpm-dev 1:3.5.17-1build2
- ubuntu resolute: libxpm-dev 1:3.5.17-1build3
- ubuntu resolute: libxpm-dev 1:3.5.17-1ubuntu0.26.04.2
- Copyright (C) 1989-95 GROUPE BULL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms