asimage(3x)
β¨ asimage β¨
okay bestie, sit down, hydrate, grab your boba π§ β because today's lesson is asimage, straight outta the AfterStep X11 window manager manual, section 3x. This is the libAfterImage lore and it is so much, in the best way π
πΈ NAME πΈ
asimage β internal structures and methods used for image manipulation in libAfterImage libAfterImage/asimage.h π
π NAMEasimage π
asimage defines main structures and function for image manipulation. she's here twice because she's iconic, periodt π
π DESCRIPTION π
libAfterImage provides powerful functionality to load, store and transform images β literally doing the most, no cap. And the way she keeps memory small? By utilizing run-length encoding of the image data. πΈ
There could be different levels of compression selected, which allows you to choose the best speed/memory ratio. so you can pick your own adventure: fast πββοΈ or smol π, your call.
π¦ SEE ALSO π¦
Structures :
ASImageASImageManagerASImageBevelASImageDecoderASImageOutputASImageLayerASGradient
Functions :
asimage_init(),asimage_start(),create_asimage(),clone_asimage(),destroy_asimage()
ImageManager Reference counting and managing :
create_image_manager(),destroy_image_manager(),store_asimage(),fetch_asimage(),query_asimage(),dup_asimage(),release_asimage(),release_asimage_by_name(),forget_asimage(),safe_asimage_destroy()
Gradients helper functions :
flip_gradient(),destroy_asgradient()
Layers helper functions :
init_image_layers(),create_image_layers(),destroy_image_layers()
Encoding :
asimage_add_line(),asimage_add_line_mono(),asimage_print_line(),get_asimage_chanmask(),move_asimage_channel(),copy_asimage_channel(),copy_asimage_lines()
Decoding
start_image_decoding(),stop_image_decoding(),asimage_decode_line (),set_decoder_shift(),set_decoder_back_color()
Output :
start_image_output(),set_image_output_back_color(),toggle_image_output_direction(),stop_image_output()
Other libAfterImage modules :
ascmap.hasfont.hasimage.hasvisual.hblender.hexport.himport.htransform.hximage.h
π AUTHOR π
Sasha Vasko <sasha at aftercode dot net> π«Ά
π libAfterImage/ASAltImFormats π
πΈ NAMEASAltImFormats πΈ
identifies what output format should be used for storing the transformation result. Also identifies what data is currently stored in alt member of ASImage structure. iykyk π
π SOURCE π
typedef enum {
ASA_ASImage = 0,
ASA_XImage,
ASA_MaskXImage,
/* temporary XImages to be allocated from static pool of memory :*/
ASA_ScratchXImage,
ASA_ScratchMaskXImage,
ASA_ScratchXImageAndAlpha,
ASA_ARGB32,
ASA_Vector, /* This cannot be used for transformation's result
* format */
ASA_Formats }ASAltImFormats;
π libAfterImage/ASImage π
β¨ NAMEASImage β¨
is the main structure to hold image data. the main character, honestly π
π DESCRIPTION π
Images are stored internally split into ARGB channels, each split into scanline. Actual data is stored using the ASStorage container. Inside the ASImage data structure we only store IDs pointing to data in ASStorage β very demure, very mindful π
And ASStorage implements reference counting, data compression, automatic memory defragmentation and other nice things. she does it all, fr fr π
π¦ SEE ALSO π¦
asimage_init()asimage_start()create_asimage()destroy_asimage()
π SOURCE π
bestie, fair warning: the struct below got kinda mangled by the original page's line wrapping, so the comments are re-flowed to be readable β every token, number and #define is exactly as it was π
struct ASImageAlternative; struct ASImageManager;
/* magic number identifying ASFont data structure */
#define MAGIC_ASIMAGE 0xA3A314AE
typedef struct ASImage {
unsigned long magic ;
unsigned int width, height; /* size of the image in pixels */
/* arrays of storage ids of stored scanlines of particular channel: */
ASStorageID *alpha,
*red,
*green,
*blue;
ASStorageID *channels[IC_NUM_CHANNELS];
/* merely a shortcut so we can
* somewhat simplify code in loops */
ARGB32 back_color ; /* background color of the image, so
* we could discard everything that
* matches it, and then restore it
* back. */
struct ASImageAlternative
{ /* alternative forms of ASImage storage : */
XImage *ximage ; /* pointer to XImage created as the
* result of transformations whenever
* we request it to output into
* XImage ( see to_xim parameter ) */
XImage *mask_ximage ; /* XImage of depth 1 that could be
* used to store mask of the image */
ARGB32 *argb32 ; /* array of widthxheight ARGB32
* values */
double *vector ; /* scientific data that should be used
* in conjunction with
* ASScientificPalette to produce
* actuall ARGB data */
}alt;
struct ASImageManager *imageman; /* if not null - then image could be
* referenced by some other code */
int ref_count ;/* this will tell us what us how many
* times */
char *name ; /* readonly copy of image name
* this name is a hash value used to
* store image in the image-man's hash,
* and gets freed automagically on image
* removal from hash */
#define ASIM_DATA_NOT_USEFUL (0x01<<0)
#define ASIM_VECTOR_TOP2BOTTOM (0x01<<1)
#define ASIM_XIMAGE_8BIT_MASK (0x01<<2)
#define ASIM_NO_COMPRESSION (0x01<<3) /* Do not use compression to
* save some computation time */
#define ASIM_ALPHA_IS_BITMAP (0x01<<4)
#define ASIM_RGB_IS_BITMAP (0x01<<5)
#define ASIM_XIMAGE_NOT_USEFUL (0x01<<6)
#define ASIM_NAME_IS_FILENAME (0x01<<7)
ASFlagType flags ; /* combination of the above flags */
} ASImage;
π§ libAfterImage/ASImageManager π§
π NAMEASImageManager π
structure to be used to maintain list of loaded images for given set of search paths and gamma. Images are named and reference counted β a whole little library of her own, obsessed πΈ
β SOURCE β
typedef struct ASImageManager {
ASHashTable *image_hash ;
/* misc stuff that may come handy : */
char *search_path[MAX_SEARCH_PATHS+1];
double gamma ; }ASImageManager;
π libAfterImage/LIMITS π
π NAMEMAX_IMPORT_IMAGE_SIZE π
MAX_IMPORT_IMAGE_SIZEβ effectively limits size of the allowed images to be loaded from files. That is needed to be able to filter out corrupt files. π«ποΈMAX_BEVEL_OUTLINEβ Limit on bevel outline to be drawn around the image.MAX_SEARCH_PATHSβ Number of search paths to be used while loading images from files.
π¦ SOURCE π¦
#define MAX_IMPORT_IMAGE_SIZE 8000
#define MAX_BEVEL_OUTLINE 100
#define MAX_SEARCH_PATHS 8 /* prudently limiting ourselfs */
π libAfterImage/ASVectorPalette π
β¨ NAMEASVectorPalette β¨
contains palette allowing us to map double values in vector image data into actuall ARGB values. translating the vibes into colors, truly her gift π
π SOURCE π
typedef struct ASVectorPalette {
unsigned int npoints ;
double *points ;
CARD16 *channels[IC_NUM_CHANNELS] ; /* ARGB data for key points. */
ARGB32 default_color; }ASVectorPalette;
π libAfterImage/asimage/ASImageLayer π
πΈ NAMEASImageLayer πΈ
specifies parameters of the image superimposition. π
π DESCRIPTION π
libAfterImage allows for simultaneous superimposition (overlaying) of arbitrary number of images β the more the merrier, bestie. To facilitate this ASImageLayer structure has been created in order to specify parameters of each image participating in overlaying operation. Images need not to be exact same size β they don't all have to match, they just have to vibe.
For each image its position on destination is specified via dst_x and dst_y data members. Each image maybe tiled and clipped to fit into rectangle specified by clip_x, clip_y, clip_width, clip_height ( in image coordinates - not destination ). If image is missing, then area specified by dst_x, dst_y, clip_width, clip_height will be filled with solid_color. Entire image will be tinted using tint parameter prior to overlaying. Bevel specified by bevel member will be drawn over image prior to overlaying. Specific overlay method has to be specified.
merge_scanlines method is pointer to a function, that accepts 2 ASScanlines as arguments and performs overlaying of first one with the second one. There are 15 different merge_scanline methods implemented in libAfterImage, including alpha-blending, tinting, averaging, HSV and HSL colorspace operations, etc. fifteen!! she ate π₯
β NOTES β
ASImageLayer s could be organized into chains using next pointers. Since there could be a need to rearrange layers and maybe bypass some layers - we need to provide for flexibility, while at the same time allowing for simplicity of arrays. As the result next pointers could be used to link together continuous arrays of layer, like so :
array1: [layer1(next==NULL)][layer2(next!=NULL)]
____________________________|
V array2:
[layer3(next==NULL)][layer4(next==NULL)][layer5(next!=NULL)]
________________________________________________|
V array3: [layer6(next==NULL)][layer7(next==layer7)]
^______|
While iterating through such a list we check for two conditions β exceeding count of layers, and layer pointing to self. When any of that is met - we stopping iteration. π
π¦ SEE ALSO π¦
merge_layers()blender.h
π SOURCE
typedef struct ASImageLayer {
ASImage *im;
ARGB32 solid_color ; /* If im == NULL, then fill
* the area with this color.
*/
int dst_x, dst_y; /* placement in overall
* composition */
/* clip area could be partially outside of the image -
* image gets tiled in it */
int clip_x, clip_y;
unsigned int clip_width, clip_height;
ARGB32 tint ; /* if 0 - no tint */
struct ASImageBevel *bevel ; /* border to wrap layer with
* (for buttons, etc.)*/
/* if image is clipped then we need to specify offsets of bevel as
* related to clipped rectangle. Normally it should be :
* 0, 0, im->width, im->height. And if width/height left 0 - it will
* default to this values. Note that clipped image MUST be entirely
* inside the bevel rectangle. !!!*/
int bevel_x, bevel_y;
unsigned int bevel_width, bevel_height;
int merge_mode ; /* reserved for future use */
merge_scanlines_func merge_scanlines ; /* overlay method */
struct ASImageLayer *next; /* optional pointer to next
* layer. If it points to
* itself - then end of the
* chain.*/
void *data; /* hook to hung data on
*/ }ASImageLayer;
libAfterImage/asimage/GRADIENT_TYPE_flags
βοΈ FUNCTION
Stack these flags together and you're literally choosing the vibe of how a gradient gets rendered. It's giving arts-and-crafts but make it bitwise. π
π·οΈ NAME
GRADIENT_TYPE_DIAG
bestie, set this and the gradient's direction gets rotated by 45 degrees β¨
GRADIENT_TYPE_ORIENTATION will rotate the gradient direction by 90 degrees. And when you combine it with GRADIENT_TYPE_DIAG? Now we're rotating the gradient direction by 135 degrees. Math is serving angles, periodt. π
π SOURCE
#define GRADIENT_TYPE_DIAG (0x01<<0)
#define GRADIENT_TYPE_ORIENTATION (0x01<<1)
#define GRADIENT_TYPE_MASK (GRADIENT_TYPE_ORIENTATION| \
GRADIENT_TYPE_DIAG)
libAfterImage/asimage/GRADIENT_TYPE
βοΈ FUNCTION
These are the named little combos of the flags from up top, so you don't have to hand-stack bits like a menace. They define the type of gradient. Pick your fighter. π
π·οΈ NAME
GRADIENT_Left2Right
the normal left-to-right gradient. The classic. The blueprint. π
GRADIENT_TopLeft2BottomRight
diagonal, top-left to bottom-right. Slay. π¦
GRADIENT_Top2Bottom
vertical, top to bottom gradient.
GRADIENT_BottomLeft2TopRight
diagonal, bottom-left to top-right. So symmetrical of it. β¨
π SOURCE
#define GRADIENT_Left2Right 0
#define GRADIENT_TopLeft2BottomRight GRADIENT_TYPE_DIAG
#define GRADIENT_Top2Bottom GRADIENT_TYPE_ORIENTATION
#define GRADIENT_BottomLeft2TopRight (GRADIENT_TYPE_DIAG| \
GRADIENT_TYPE_ORIENTATION)
libAfterImage/ASGradient
π·οΈ NAME
ASGradient
okay so this one describes how a gradient is actually to be drawn. π
π¬ DESCRIPTION
libAfterImage is lowkey stacked β it can draw multipoint gradients in 4 different directions: left->right, top->bottom, and the two diagonals, lefttop->rightbottom and bottomleft->topright. Obsessed.
Every gradient is described by:
- its type,
- the number of colors (aka anchor points),
- the ARGB values for each color,
- and the offsets of each point from the beginning of the gradient, expressed as fractions of the entire length.
House rules, no exceptions: there have to be at least 2 anchor points, the very first point should have an offset of 0., and the last point should have an offset of 1. π
Gradients get drawn in ARGB colorspace, which means yes bestie β you can absolutely have semitransparent gradients. Main character energy. β¨
π SEE ALSO
make_gradient()
π SOURCE
typedef struct ASGradient {
int type; /* see GRADIENT_TYPE above */
int npoints; /* number of anchor points */
ARGB32 *color; /* ARGB color values for each anchor point*/
double *offset; /* offset of each point from the beginning in
* fractions of entire length */
}ASGradient;
libAfterImage/asimage/flip
βοΈ FUNCTION
These are the flags that define the rotation angle. Rotating is just a vibe check for your pixels. π
π·οΈ NAME
FLIP_VERTICAL
defines rotation of 90 degrees counterclockwise.
FLIP_UPSIDEDOWN
defines rotation of 180 degrees counterclockwise.
And when you combine them together? Boom β that defines rotation of 270 degrees counterclockwise. Stacking flags is the moment. π
π SOURCE
#define FLIP_VERTICAL (0x01<<0)
#define FLIP_UPSIDEDOWN (0x01<<1)
#define FLIP_MASK (FLIP_UPSIDEDOWN|FLIP_VERTICAL)
libAfterImage/asimage/flip_gradient()
π·οΈ NAME
flip_gradient()
rotates a gradient in 90 degree increments. Iconic behavior honestly.
π SYNOPSIS
ASGradient *flip_gradient( ASGradient *orig, int flip );
π₯ INPUTS
origβ pointer to the originalASGradientstructure that's gonna get rotated.flipβ the value defining the desired rotation.
π€ RETURN VALUE
Same as the original gradient if flip is 0. A new gradient structure in any other case. π«Ά
π¬ DESCRIPTION
Rotates (flips) gradient data in 90 degree increments. And when it needs to, the order of points gets reversed. Simple as that, bestie. Reversal is just a glow-up in a different direction. β¨
libAfterImage/asimage/tint
βοΈ FUNCTION
So we use 32 bit ARGB values to define how tinting should be done. Here's the formula for tinting a particular channel's data:
tinted_data = (image_data * tint)/128
Let's break it down, because this is actually so important:
- If the tint channel value is greater than 127 β that same channel will be brighter in the destination image. β¨
- If it's lower than 127 β that same channel will be darker in the destination image.
- A tint channel value of 127 (or
0x7Fhex) changes nothing. Neutral king. π
The alpha channel gets tinted as well, which allows for the creation of semitransparent images. Yes bestie, transparency is on the menu. ππ
Calculations are performed in 24.8 format β with 8 bit precision. The result is saturated to avoid overflow, and the leftover precision is carried over to the next pixel (that's called error diffusion), when converting 24.8 to 8 bit format. Details matter and we stay detail-oriented. π
π·οΈ NAME
TINT_NONE
special value that disables tinting. Zero tint, zero drama.
TINT_LEAVE_SAME
also disables tinting. Same energy, different constant. π
π SOURCE
#define TINT_NONE 0
#define TINT_LEAVE_SAME (0x7F7F7F7F)
#define TINT_HALF_DARKER (0x3F3F3F3F)
#define TINT_HALF_BRIGHTER (0xCFCFCFCF)
#define TINT_RED (0x7F7F0000)
#define TINT_GREEN (0x7F007F00)
#define TINT_BLUE (0x7F00007F)
libAfterImage/asimage/compression
βοΈ FUNCTION
Defines the level of compression to attempt on ASImage scanlines. Squish at your own discretion. ποΈ
π·οΈ NAME
ASIM_COMPRESSION_NONE
defined as 0 β disables compression. Nothing gets squished.
ASIM_COMPRESSION_FULL
defined as 100 β the highest compression level. Maximum squish. π₯
Anything in between 0 and 100 will cause only part of the scanline to be compressed. And okay, tea time: this is obsolete. Now all images are compressed if possible. So don't come to this option expecting modern behavior, bestie. π
libAfterImage/asimage/asimage_init()
π·οΈ NAME
asimage_init()
frees datamembers of the supplied ASImage structure, and initializes it to all 0. Reset era. πΈ
π SYNOPSIS
void asimage_init (ASImage * im, Bool free_resources);
π₯ INPUTS
imβ pointer to a validASImagestructure.free_resourcesβ ifTrue, will make the function attempt to free all non-NULLpointers.
libAfterImage/asimage/flush_asimage_cache()
π·οΈ NAME
flush_asimage_cache()
destroys XImage and mask XImage kept from previous conversions to/from X Pixmap. Clearing the cache, clearing the clutter. π§Ή
π SYNOPSIS
void flush_asimage_cache (ASImage * im );
π₯ INPUTS
imβ pointer to a validASImagestructure.
libAfterImage/asimage/asimage_start()
π·οΈ NAME
asimage_start()
Allocates the memory needed to store a scanline of the image of the supplied size. Assigns all the data members valid values. Makes sure that the ASImage structure is ready to store image data. Getting the whole thing prepped and cute. π
π SYNOPSIS
void asimage_start (ASImage * im, unsigned int width,
unsigned int height,
unsigned int compression);
π₯ INPUTS
imβ pointer to a validASImagestructure.widthβ width of the image.heightβ height of the image.compressionβ level of compression to perform on image data.compressionhas to be in the range of0-100, with100signifying the highest level of compression.
π NOTES
Heads up bestie: in order to resize anASImagestructure afterasimage_start()has been called, you must invokeasimage_init()first to free all the memory, and then callasimage_start()with the new dimensions. No shortcuts, no skipping steps. π
libAfterImage/asimage/create_asimage()
π·οΈ NAME
create_asimage()
Performs memory allocation for the new ASImage structure, plus initialization of that freshly allocated structure based on the supplied parameters. Born ready. β¨
π SYNOPSIS
ASImage *create_asimage( unsigned int width,
unsigned int height,
unsigned int compression);
π₯ INPUTS
widthβ desired image width.heightβ desired image height.compressionβ compression level in the newASImage(seeasimage_start()for more).
π€ RETURN VALUE
Pointer to the newly allocated and initialized ASImage structure on Success. NULL in case of any kind of error β which, and I quote, should never happen. π
libAfterImage/asimage/clone_asimage()
π·οΈ NAME
clone_asimage()
π SYNOPSIS
ASImage *clone_asimage(ASImage *src, ASFlagType filter );
π₯ INPUTS
srcβ the originalASImage.filterβ bitmask of channels to be copied from one image to another.
π€ RETURN VALUE
A new ASImage, as a copy of the original image. π«Ά
π¬ DESCRIPTION
Creates an exact clone of the original ASImage, with the same compression, back_color and the rest of the attributes. Only ASImage data will be carried over. Any attached alternative forms of images (XImages, etc.) will not be copied. And any channel with an unset bit in filter will not be copied either β you're literally choosing what comes along for the ride.
Important: Image name,ASImageManagerandref_countwill not be copied β usestore_asimage()afterwards, and make sure you use a different name, to avoid clashes with the original image. No identity theft in this house. π
libAfterImage/asimage/destroy_asimage()
π·οΈ NAME
destroy_asimage()
frees all the memory allocated for the specified ASImage. Cleanup era, we love to see it. πΈ
π SYNOPSIS
void destroy_asimage( ASImage **im );
π₯ INPUTS
imβ pointer to a validASImagestructure.
π NOTES
If there was an XImage attached to it β that gets deallocated as well. No stragglers, no leftovers. β¨
π EXAMPLE
asview.c: ASView.5
libAfterImage/asimage/asimage_replace()
π·οΈ NAME
asimage_replace()
will replace ASImage's data using data from another ASImage. Glow-up via swap. π
π SYNOPSIS
Bool asimage_replace (ASImage *im, ASImage *from);
π₯ INPUTS
imβ pointer to a validASImagestructure.fromβ pointer to theASImagefrom which to take the data.
π NOTES
This function updates the image without reallocating the structure itself, which means all pointers to it will still be valid. Bestie, that's the whole point. π
But listen: if that function succeeds β thefromASImagewill become unusable and should be deallocated using afree()call. It gave everything it had. π«Ά
libAfterImage/asimage/set_asimage_vector()
π·οΈ NAME
set_asimage_vector()
This function replaces contents of the vector member of the ASImage structure with new double precision data. New data, who dis. β¨
π SYNOPSIS
set_asimage_vector( ASImage *im, register double *vector );
imβ pointer to a validASImagestructure, bestie. like, an actual one, not a vibe πvectorβ the scientific data you're attaching to the image. yes, actual numbers. slay π₯
β¨ NOTES β¨
okay so listen β the data has to have size of width*height, where width and height are the size of the ASImage. no shortcuts, no "close enough". the math has to math. πΈ
libAfterImage/asimage/vectorize_asimage()
π NAME β vectorize_asimage() π«
this one replaces the contents of the vector member of the ASImage structure with brand new double precision data, generated from native ARGB32 image contents. and the color palette? generated by indexing color values using the max_colors, dither and opaque_threshold parameters. iconic behavior honestly π
π¦ SYNOPSIS π¦
ASVectorPalette* vectorize_asimage( ASImage *im,
unsigned int max_colors,
unsigned int dither,
int opaque_threshold );
π INPUTS π
imβ pointer to validASImagestructure. π«Άmax_colorsβ maximum size of the colormap.ditherβ number of bits to strip off the color data (0...7). yes that's the range. don't be weird about it.opaque_thresholdβ alpha channel threshold at which pixel should be treated as opaque
π RETURN VALUE π
pointer to the ASVectorPalette structure that could be used for reverse conversion from double values to ARGB32. it's giving utility. it's giving round trip. β¨
π NOTES π
the alt.vector member of the supplied ASImage will be replaced, and will contain WIDTHxHEIGHT double values representing generated scientific data. so like, heads up β your old data is gone gone. π
libAfterImage/asimage/create_image_manager()
π NAME β create_image_manager() π
create ASImage management and reference counting object. it's literally the adult supervision of your images. π§
π¦ SYNOPSIS π¦
ASImageManager *create_image_manager( ASImageManager *reusable_memory,
double gamma, ... );
π INPUTS π
reusable_memoryβ optional pointer to a block of memory to be used to storeASImageManagerobject.double gammaβ value of gamma correction to be used while loading images from files....βNULLterminated list of up to 8PATHstrings to list locations at which images could be found. up to 8, bestie. not 9. do not.
πΈ DESCRIPTION πΈ
Creates the ASImageManager object in memory and initializes it with the requested gamma value and PATH list. This object will contain a hash table referencing all the loaded images. When such an object is used while loading images from the file β gamma and PATH values will be used, so that all the loaded and referenced images will have same parameters. fr fr consistent.
File name will be used as the image name, and if the same file is attempted to be loaded again β instead the reference will be incremented, and the previously loaded image will be returned. no double loading, no wasted memory, main character efficiency. π
All the images stored in ASImageManager's table will contain a back pointer to it, and they must be deallocated only by calling release_asimage(). destroy_asimage() will refuse to deallocate such an image. so like, respect the chain of command ok π€
libAfterImage/asimage/destroy_image_manager()
π NAME β destroy_image_manager() π
destroy management object. (the source says "obejct", but the vibe is destruction either way.)
π¦ SYNOPSIS π¦
void destroy_image_manager( struct ASImageManager *imman,
Bool reusable );
π INPUTS π
immanβ pointer toASImageManagerobject to be deallocatedreusableβ ifTrue, then memory that holds object itself will not be deallocated. Useful when object is created on stack. π«Ά
πΈ DESCRIPTION πΈ
Destroys all the referenced images, PATH values, and if reusable is False, also deallocates object's memory. full cleanout. no survivors. β¨
libAfterImage/asimage/store_asimage()
π NAME β store_asimage() π
add ASImage to the reference. put it in the group chat, essentially.
π¦ SYNOPSIS π¦
Bool store_asimage( ASImageManager* imageman, ASImage *im,
const char *name );
π INPUTS π
imagemanβ pointer to validASImageManagerobject.imβ pointer to the image to be stored.nameβ unique name of the image. unique, okay? that's the whole point. π
πΈ DESCRIPTION πΈ
Adds the specified image to the ASImageManager's list of referenced images. A stored ASImage could be deallocated only by release_asimage(), or when the ASImageManager object itself is destroyed. those are the rules. periodt. π
libAfterImage/asimage/relocate_asimage()
π NAME β relocate_asimage() π¦
relocate ASImage into a different image manager. moving day, but for pointers. π¦
π¦ SYNOPSIS π¦
void relocate_asimage( ASImageManager* to_imageman, ASImage *im );
π INPUTS π
to_imagemanβ pointer to validASImageManagerobject. (this is the destination, the new home π‘)imβ pointer to the image to be stored.
πΈ DESCRIPTION πΈ
Moves image from one ASImageManager's list of referenced images into another ASImageManager. Reference count will be kept the same. no drama, no recount, it just slides over. π
libAfterImage/asimage/fetch_asimage()
π NAME β fetch_asimage(), query_asimage() π
π¦ SYNOPSIS π¦
ASImage *fetch_asimage( ASImageManager* imageman, const char *name );
ASImage *query_asimage( ASImageManager* imageman, const char *name );
π INPUTS π
imagemanβ pointer to validASImageManagerobject.nameβ unique name of the image.
πΈ DESCRIPTION πΈ
Looks for image with the name in ASImageManager's list and if found, returns pointer to it. here's the crucial difference bestie: query_asimage() does not increment the reference count, while fetch_asimage() does. Therefore if fetch_asimage() is used β release_asimage() should be called, when image is no longer in use. the way that forgetting this leaks memory π
libAfterImage/asimage/dup_asimage()
π NAME β dup_asimage() π
increment reference count of stored ASImage. it's giving "me too, me too!"
π¦ SYNOPSIS π¦
ASImage *dup_asimage( ASImage* im );
π INPUTS π
imβ pointer to already referenced image.
libAfterImage/asimage/release_asimage()
π NAME β release_asimage() π
decrement reference count for given ASImage. and release_asimage_by_name() decrements reference count for ASImage identified by its name. two icons, one entry.
π¦ SYNOPSIS π¦
int release_asimage( ASImage *im );
int release_asimage_by_name( ASImageManager *imman, char *name );
π INPUTS π
imβ pointer to already referenced image.imagemanβ pointer to validASImageManagerobject.nameβ unique name of the image.
πΈ DESCRIPTION πΈ
Decrements reference count on the ASImage object and destroys it if reference count is below zero. that's it. that's the whole job. clean, simple, slay. β¨
libAfterImage/asimage/forget_asimage()
π NAME β forget_asimage() π«₯
remove ASImage from ASImageManager's hash by pointer. and forget_asimage_name() removes ASImage from ASImageManager's hash by its name. two ways to be forgotten, bestie π
π¦ SYNOPSIS π¦
void forget_asimage( ASImage *im );
void forget_asimage_name( ASImageManager *imman, const char *name );
π INPUTS π
imβ pointer to already referenced image.imagemanβ pointer to validASImageManagerobject.nameβ unique name of the image.
libAfterImage/safe_asimage_destroy()
π NAME β safe_asimage_destroy() π‘οΈ
either release or destroy the asimage, checking if it is attached to an ASImageManager. it's the "look before you leap" of destructors. ngl kind of the responsible friend of the group. π«Ά
π¦ SYNOPSIS π¦
int safe_asimage_destroy( ASImage *im );
π INPUTS π
imβ pointer to anASImagestructure.
libAfterImage/print_asimage_manager()
π NAME β print_asimage_manager() π¨οΈ
prints list of images referenced in given ASImageManager structure. a little roster. a little attendance sheet. attendance is mandatory btw. π
libAfterImage/asimage/destroy_asgradient()
π NAME β destroy_asgradient() π
- destroy
ASGradientstructure, deallocating all associated memory. gradient's over, babe. it served its lewk and now it's gone. π«
libAfterImage/asimage/init_image_layers()
π NAME β init_image_layers() π§
- initialize set of
ASImageLayerstructures.
π¦ SYNOPSIS π¦
void init_image_layers( register ASImageLayer *l, int count );
π INPUTS π
lβ pointer to validASImageLayerstructure.countβ number of elements to initialize.
πΈ DESCRIPTION πΈ
Initializes an array of ASImageLayer structures to sensible defaults. Basically β all zeros and merge_scanlines == alphablend_scanlines. like a fresh notepad. blank slate energy. β¨
libAfterImage/asimage/create_image_layers()
π NAME β create_image_layers() π
- allocate and initialize set of
ASImageLayer's.
π¦ SYNOPSIS π¦
ASImageLayer *create_image_layers( int count );
π INPUTS π
countβ number ofASImageLayerstructures in allocated array.
π RETURN VALUE π
Pointer to newly allocated and initialized array of ASImageLayer structures on Success. NULL in case of any kind of error β that should never happen. (should never happen is doing a lot of heavy lifting in that sentence ngl π)
πΈ DESCRIPTION πΈ
Performs memory allocation for the new array of ASImageLayer structures, as well as initialization of the allocated structure to sensible defaults β merge_func will be set to alphablend_scanlines. yes it pre-sets that for you. she's thoughtful like that. π
libAfterImage/asimage/destroy_image_layers()
π NAME β destroy_image_layers() π₯
- destroy set of
ASImageLayerstructures.
π¦ SYNOPSIS π¦
void destroy_image_layers( register ASImageLayer *l,
int count,
Bool reusable );
π INPUTS π
lβ pointer to pointer to valid array ofASImageLayerstructures.countβ number of structures in array.reusableβ ifTrueβ then array itself will not be deallocated β which is usable when it was allocated on stack. π«Ά
πΈ DESCRIPTION πΈ
frees all the memory allocated for the specified array of ASImageLayers. If there was an ASImage and/or ASImageBevel attached to it β it will be deallocated as well. yes, they come down with the ship. collateral cleanup. π
libAfterImage/asimage/asimage_add_line()
π NAME β asimage_add_line() β
π¦ SYNOPSIS π¦
size_t asimage_add_line ( ASImage * im, ColorPart color,
CARD32 * data, unsigned int y);
π INPUTS π
imβ pointer to validASImagestructurecolorβ color channel's numberdataβ raw channel data of 32 bits per pixel β only lowest 8 bits gets encoded. only the bottom 8. the rest get ignored, like your ex's texts. πyβ image row starting with 0
π RETURN VALUE π
asimage_add_line() returns size of the encoded channel scanline in bytes. On failure it will return 0. zero. nada. red flag check. π©
πΈ DESCRIPTION πΈ
Encodes raw data of the single channel into an ASImage channel scanline. Based on the compression level selected for this ASImage, all or part of the scanline will be RLE encoded. compression said "I'll take some of it" and honestly? valid. π₯
libAfterImage/asimage/asimage_add_line_mono()
π NAME β asimage_add_line_mono() π
π¦ SYNOPSIS π¦
size_t asimage_add_line_mono ( ASImage * im, ColorPart color,
CARD8 value, unsigned int y);
π INPUTS π
imβ pointer to validASImagestructurecolorβ color channel's numbervalueβ value for the channelyβ image row starting with 0
π RETURN VALUE π
asimage_add_line_mono() returns size of the encoded channel scanline in bytes. On failure it will return 0.
πΈ DESCRIPTION πΈ
encodes ASImage channel scanline to have the same color components value in every pixel. Useful for vertical gradients for example. yes, every single pixel. uniformity. consistency. a little bit of monotony, but in a chic way. π
libAfterImage/asimage/get_asimage_chanmask()
π NAME β get_asimage_chanmask() π
π¦ SYNOPSIS π¦
ASFlagType get_asimage_chanmask( ASImage *im);
π INPUTS π
imβ validASImageobject.
πΈ DESCRIPTION πΈ
goes through all the scanlines of the ASImage and toggles bits representing those components that have at least some data. it's basically doing a vibe check on each channel β do you have data or not, bestie? π
libAfterImage/asimage/move_asimage_channel()
π NAME β move_asimage_channel() π¦
π¦ SYNOPSIS π¦
void move_asimage_channel( ASImage *dst, int channel_dst,
ASImage *src, int channel_src );
π INPUTS π
dstβASImagewhich will have its channel substituted;channel_dstβ what channel to move data to;srcβASImagewhich will donate its channel todst;channel_srcβ what source image channel to move data from.
πΈ DESCRIPTION πΈ
MOves channel data from one ASImage to another, while discarding what was already in destination's channel. so the destination's old data? gone. no merge, no blend, no compromise. out with the old, in with the donated. π«
πΈ NOTES πΈ
okay so bestie, listen β these are the receipts you need before you touch any of this π
The source image (aka the donor, the one giving the gift π) is gonna lose all its channel data, because that data is getting moved into the destination ASImage. It's not a copy, it's a relocation. The donor walks away with nothing. RIP to it fr π
Also there's a whole condition here: both images must be the same width. If they're not? The function justβ¦ returns. Does nothing. No error, no drama, just vibes and silence π
But if the heights differ? No problem β the minimum of the two gets used. Slay, adaptive β¨
libAfterImage/asimage/copy_asimage_channel()
π NAME π
copy_asimage_channel()
β¨ SYNOPSIS β¨
void copy_asimage_channel( ASImage *dst, int channel_dst,
ASImage *src, int channel_src );
π INPUTS π
dstβ theASImagethat's about to get one of its channels swapped out, main character energy πchannel_dstβ which channel we're copying the data tosrcβ theASImagedonating its channel todst, so generous π«Άchannel_srcβ which channel on the source image we're copying the data from
π¦ DESCRIPTION π¦
Same as move_asimage_channel(), except β and this is the whole plot twist β it makes an actual copy of the channel's data instead of just yeeting it from one image to the other. Original stays. Iconic, non-destructive behavior π
libAfterImage/asimage/copy_asimage_lines()
π NAME π
copy_asimage_lines()
β¨ SYNOPSIS β¨
void copy_asimage_lines( ASImage *dst, unsigned int offset_dst,
ASImage *src, unsigned int offset_src,
unsigned int nlines, ASFlagType filter );
π INPUTS π
dstβ theASImagegetting its channel substitutedoffset_dstβ the scanline in the destination image you're copying tosrcβ theASImagedonating its channel todstoffset_srcβ the scanline in the source image you're copying data fromnlinesβ how many scanlines are getting copiedfilterβ tells us which channels should actually be copied, gatekeeping as it should π
π¦ DESCRIPTION π¦
It copies scanline data for a continuous set of scanlines, and it only touches the channels that are marked in filter. Selective queen β¨
NOTE: the images must be the same width. No negotiation.
libAfterImage/asimage/verbosity
π FUNCTION π
These are the flags that decide what asimage_print_line() actually prints out:
VRB_LINE_SUMMARYβ just the summary for each scanline, no oversharing πVRB_LINE_CONTENTβ the summary and the data for each scanlineVRB_CTRL_EXPLAINβ the summary, the data, and the control codes for each scanline. Full transparency, we love to see it π
π SOURCE π
#define VRB_LINE_SUMMARY (0x01<<0)
#define VRB_LINE_CONTENT (0x01<<1)
#define VRB_CTRL_EXPLAIN (0x01<<2)
#define VRB_EVERYTHING (VRB_LINE_SUMMARY|VRB_CTRL_EXPLAIN| \
VRB_LINE_CONTENT)
libAfterImage/asimage/asimage_print_line()
π NAME π
asimage_print_line()
β¨ SYNOPSIS β¨
unsigned int asimage_print_line ( ASImage * im, ColorPart color,
unsigned int y,
unsigned long verbosity);
π INPUTS π
imβ pointer to a validASImagestructurecolorβ the color channel's numberyβ image row, and it starts counting at 0 (zero-indexed girlies rise up π)verbosityβ the verbosity level; any combination of flags is allowed, mix and match bestie
π₯ RETURN VALUE π₯
The amount of memory used by this particular channel of the specified scanline. Numbers, but make it fashion π
π¦ DESCRIPTION π¦
asimage_print_line() prints the data stored in the channel of the specified image scanline. That can include a simple summary of how much memory is used, the actual visible data, and/or RLE control codes. Basically it helps you see how effectively the data is encoded. Vibe check on your compression π
Mostly useful for debugging purposes. She's a dev tool, not a spotlight girlie π
libAfterImage/asimage/get_asimage_channel_rects()
π NAME π
get_asimage_channel_rects() β translate image into a list of rectangles.
β¨ SYNOPSIS β¨
XRectangle*
get_asimage_channel_rects( ASImage *src, int channel,
unsigned int threshold,
unsigned int *rects_count_ret );
π INPUTS π
srcβASImagewhich will donate its channel todstchannelβ what source image channel to copy data fromthresholdβ the threshold that channel values get compared againstrects_count_retβ returns the count of generated rectangles
π¦ DESCRIPTION π¦
This one translates the contents of a selected channel (usually alpha, the shy one) into a whole list of rectangles, encompassing the regions where values are above the threshold. Super useful for generating the shape of a window to use with the X Shape extension. Window shaped like a butterfly? Possible. π¦β¨
aaaaand that's the whole page bestie, you made it to the end, so proud of you fr fr π₯Ήπ This was AfterStep v.2.2.12, from the 3rd Berkeley Distribution, and asimage(3x) says hi and hopes you slayed ππ
periodt. π
π¦ 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