import(3x)
πΈ NAME πΈ
okay bestie, gather round π this is import(3x) β the glow-up page for the AfterStep X11 window manager's import situation. Real talk:
importβ functionality for reading images from files- and it lives in
libAfterImage/import.hπ
β¨ NAMEimport β¨
import is literally the icon of image file format autodetection, plus all the reading and decoding routines that go with it. no cap π
π¦ SEE ALSO π¦
Functions (the besties it runs with):
file2ASImage()get_asimage()file2pixmap()
Other libAfterImage modules (the whole friend group π«Ά):
ascmap.hasfont.hasimage.hasvisual.hblender.hexport.himport.htransform.hximage.h
π AUTHOR π
Sasha Vasko β <sasha at aftercode dot net> π absolute legend, main character energy fr fr.
Also tagging along in this section: libAfterImage/gamma π
π NAMESCREEN_GAMMA π
defines the default value for screen gamma correction. that's it, that's the whole vibe β¨
π« SOURCE π«
#define SCREEN_GAMMA 2.2 #define DEFAULT_PNG_IMAGE_GAMMA 0.45455
π libAfterImage/ASImageFileTypes π
β¨ NAMEASImageFileTypes β¨
it's the list of known image file formats. like the guest list but for file types π
π« SOURCE π«
typedef enum {
ASIT_Xpm = 0,
ASIT_ZCompressedXpm,
ASIT_GZCompressedXpm,
ASIT_Png,
ASIT_Jpeg,
ASIT_Xcf,
ASIT_Ppm,
ASIT_Pnm,
ASIT_Bmp,
ASIT_Ico,
ASIT_Cur,
ASIT_Gif,
ASIT_Tiff,
ASIT_XMLScript,
ASIT_SVG,
/* reserved for future implementation : */
ASIT_Xbm,
ASIT_Targa,
ASIT_Supported = ASIT_Targa,
ASIT_Pcx,
ASIT_HTML,
ASIT_XML,
ASIT_Unknown }ASImageFileTypes;
π§ libAfterImage/ASImageListEntry π§
β¨ NAMEASImageListEntry β¨
one entry in a linked list of images loaded from a single directory π (bestie, it's a whole linked list β prev and next and everything, so dramatic).
π« SOURCE π«
typedef struct ASImageListEntryBuffer {
#define ASILEB_Dirty (0x01<<0)
#define ASILEB_Binary (0x01<<1)
ASFlagType flags ;
size_t size ;
char *data ;
}ASImageListEntryBuffer;
typedef struct ASImageListEntry {
#define MAGIC_ASIMAGE_LIST_ENTRY 0xA3A311E4
#define IS_ASIMAGE_LIST_ENTRY(e) (((e)!=NULL)&&((e)->magic==MAGIC_ASIMAGE_LIST_ENTRY)&&((e)->ref_count>0))
unsigned long magic ;
struct ASImageListEntry *prev, *next ;
char *name ;
char *fullfilename ;
ASImageFileTypes type;
ASImage *preview;
#ifndef _WIN32
mode_t d_mode;
#endif
time_t d_mtime;
off_t d_size; /* total size, in bytes */
ASImageListEntryBuffer *buffer ;
int ref_count;
}ASImageListEntry;
π libAfterImage/import/file2ASImage() π
πΈ NAMEfile2ASImage() πΈ
load an ASImage from a file. yes it's giving exactly what it says on the tin β¨
π« SYNOPSIS π«
ASImage *file2ASImage( const char *file, ASFlagType what,
double gamma,
unsigned int compression, ... );
π INPUTS π
fileβ file name, with or without a directory namewhatβ reserved for future use (so, placeholder core, don't come for her π)gammaβ the gamma value used to correct the imagecompressionβ the compression level of the resultingASImage...β aNULL-terminated list of strings, representing an arbitrary number of directories to be searched. each one. yes, each. π
β RETURN VALUE β
A pointer to the ASImage structure holding the image data on success. NULL on failure, bestie π
π¦ DESCRIPTION π¦
so file2ASImage is gonna try to interpret that filename in the following ways, in order:
- It will try to find the file using the unmodified filename in all the provided search paths.
- It will attempt to append
.gzand then.Zto the filename and find such a file in all the provided search paths. - If the filename ends with an extension consisting of digits only, it will attempt to find the file with this extension stripped off. On success, this extension will be used to load a subimage from the file with that number. Heads up: subimages are supported only for XCF, GIF, BMP, ICO and CUR files β that's the whole list, no extras π
After the file is found, file2ASImage() attempts to detect the file format, and if it's a known one, it will load it into a new ASImage structure. slay.
π₯ EXAMPLE π₯
asview.c: ASView.2
π libAfterImage/import/get_asimage() π
πΈ NAMEget_asimage() πΈ
increments the reference counter if the file is already loaded, or loads the image from the file if it isn't. efficient queen behavior π
π« SYNOPSIS π«
ASImage *get_asimage( ASImageManager* imageman, const char *file,
ASFlagType what, unsigned int compression );
π INPUTS π
real talk, the descriptions here are exactly what the page says, so I'm passing them along verbatim β they do not match the argument names and I am NOT fixing that, that's not my job π
imagemanβ pointer to a validASVisualstructure.fileβ root window ID for the destination screen.whatβ the full image file's name with path.compressionβ (and that's it, it's giving nothing, there's no description here π)
β RETURN VALUE β
Pointer to the ASImage structure holding the image data on success. NULL on failure π
π¦ DESCRIPTION π¦
get_asimage will first check the ASImageManager's list of loaded images, and if an image with the requested filename already exists β it will increment its reference count and return its pointer. no reload, no drama, we love a cache hit π
Otherwise it will call file2ASImage() to load the image from the file. It uses the PATH and gamma values from the ASImageManager and passes them to file2ASImage(). If the image is successfully loaded, it gets added to the ASImageManager's list and its pointer gets returned. periodt. β¨
π SEE ALSO π
file2ASImage()
π libAfterImage/import/file2pixmap() π
πΈ NAMEfile2pixmap() πΈ
the convenience function that loads a file straight into an X Pixmap π (convenience is her middle name).
π« SYNOPSIS π«
Pixmap file2pixmap( struct ASVisual *asv, Window root,
const char *realfilename,
Pixmap *mask_out);
π INPUTS π
asvβ pointer to a validASVisualstructure.rootβ root window ID for the destination screen.realfilenameβ the full image file's name with path.
β RETURN VALUE β
The Pixmap ID of the X Pixmap filled with the loaded image. If mask_out is not NULL, it will point to the image mask Pixmap ID if there is an alpha channel in the image, and None otherwise. On failure, None will be returned. π
π¦ DESCRIPTION π¦
file2pixmap() will attempt to open the specified file and autodetect its format. If the format is known, it loads it into an ASImage first, and then converts it into an X Pixmap. And in case the image has an alpha channel β a mask Pixmap will be produced, but only if mask_out is not NULL. iconic.
okay bestie that's the whole page π no notes, we ate. this was import(3x) from AfterStep v.2.2.12, brought to you by the 3rd Berkeley Distribution β stay hydrated, read your manpages, and may all your file formats autodetect on the first try πΈβ¨π¦π
π
π¦ where this page comes from
- ubuntu resolute: libafterimage-dev 2.2.12-19 Β· GPL-2.0-or-later
- ubuntu stonking: libafterimage-dev 2.2.12-19 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms