ximage(3x)

✨ NAME ✨

okay so bestie, welcome to ximage(3x) β€” yep, that's the section 3 page from the AfterStep X11 window manager, and it's all about the libAfterImage module that hangs out in libAfterImage/ximage.h. πŸ’–

ximage β€” functionality for displaying ASImages on X display

libAfterImage/ximage.h


🌈 NAME β€” ximage 🌈

ok so this bit defines the whole conversion pipeline both ways: X stuff into ASImages, and ASImages back out into X stuff. Defines conversion to and from XImages and Pixmaps. ✨


πŸ’… DESCRIPTION πŸ’…

here's the whole friend group, one by one, and what each of them does:

  • ximage2asimage() β€” convert XImage structure into ASImage
  • pixmap2asimage() β€” convert X11 pixmap into ASImage
  • asimage2ximage() β€” convert ASImage into XImage
  • asimage2mask_ximage() β€” convert alpha channel of ASImage into XImage
  • asimage2pixmap() β€” convert ASImage into Pixmap (possibly using precreated XImage)
  • asimage2mask() β€” convert alpha channel of ASImage into 1 bit mask Pixmap.

πŸ” SEE ALSO πŸ”

Other libAfterImage modules, aka the rest of the extended universe πŸ¦‹:

ascmap.h asfont.h asimage.h asvisual.h blender.h export.h import.h transform.h ximage.h


πŸ‘‘ AUTHOR πŸ‘‘

Sasha Vasko <sasha at aftercode dot net> β€” the icon who wrote all this, no cap. 🫢


πŸ“ libAfterImage/picture_ximage2asimage()

✨ NAME ✨ β€” picture_ximage2asimage()

πŸŽ€ SYNOPSIS πŸŽ€

ASImage *picture_ximage2asimage ( struct ASVisual *asv,
                                  XImage * xim, XImage *alpha_xim,
                                  unsigned int compression );

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • xim β€” source XImage
  • alpha_xim β€” source XImage for Alpha channel
  • compression β€” degree of compression of resulting ASImage.

πŸ“ RETURN VALUE πŸ“

pointer to newly allocated ASImage, containing encoded data, on success. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

picture_ximage2asimage will attempt to create new ASImage with the same dimensions as supplied XImage. If both XImages are supplied β€” they must have same dimensions. XImage will be decoded based on supplied ASVisual, and resulting scanlines will be encoded into ASImage. ✨

fr fr: if you hand it two XImages, they must match in size. no exceptions, bestie.

πŸ“ libAfterImage/ximage2asimage()

✨ NAME ✨ β€” ximage2asimage()

same as picture_ximage2asimage with alpha_ximage set to NULL. Supplied for compatibility with older versions and for convenience. 🌸

πŸŽ€ SYNOPSIS πŸŽ€

ASImage *ximage2asimage ( struct ASVisual *asv, XImage * xim,
                          unsigned int compression );

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • xim β€” source XImage
  • compression β€” degree of compression of resulting ASImage.

πŸ“ RETURN VALUE πŸ“

pointer to newly allocated ASImage, containing encoded data, on success. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

(no alpha, no drama β€” it's the streamlined version of the big one up top 🫢)


πŸ“ libAfterImage/pixmap2asimage()

✨ NAME ✨ β€” pixmap2asimage()

πŸŽ€ SYNOPSIS πŸŽ€

ASImage *pixmap2ximage( ASVisual *asv, Pixmap p, int x, int y,
                        unsigned int width, unsigned int height,
                           unsigned long plane_mask,
                        unsigned int compression);

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • p β€” source Pixmap
  • x, y, width, height β€” rectangle on Pixmap to be encoded into ASImage.
  • plane_mask β€” limits color planes to be copied from Pixmap.
  • keep_cache β€” indicates if we should keep XImage, used to copy image data from the X server, and attached it to ximage member of resulting ASImage.
  • compression β€” degree of compression of resulting ASImage.

πŸ“ RETURN VALUE πŸ“

pointer to newly allocated ASImage, containing data in XImage format, on success. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

pixmap2ximage will obtain XImage of the requested area of the X Pixmap, and it will attach it to newly created ASImage using alt.ximage member. After that newly created ASImage could be used in any transformations. πŸ”₯


πŸ“ libAfterImage/pixmap2asimage()

✨ NAME ✨ β€” pixmap2asimage()

πŸŽ€ SYNOPSIS πŸŽ€

ASImage *pixmap2asimage ( struct ASVisual *asv, Pixmap p,
                          int x, int y,
                          unsigned int width,
                          unsigned int height,
                          unsigned long plane_mask,
                          Bool keep_cache,
                          unsigned int compression );

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • p β€” source Pixmap
  • x, y, width, height β€” rectangle on Pixmap to be encoded into ASImage.
  • plane_mask β€” limits color planes to be copied from Pixmap.
  • keep_cache β€” indicates if we should keep XImage, used to copy image data from the X server, and attached it to ximage member of resulting ASImage.
  • compression β€” degree of compression of resulting ASImage.

πŸ“ RETURN VALUE πŸ“

pointer to newly allocated ASImage, containing encoded data, on success. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

same as picture2asimage() with alpha pixmap set to None. Supplied for compatibility and convenience. 😌


πŸ“ libAfterImage/picture2asimage()

✨ NAME ✨ β€” picture2asimage()

πŸŽ€ SYNOPSIS πŸŽ€

ASImage *picture2asimage (struct ASVisual *asv,
                          Pixmap rgb, Pixmap a,
                          int x, int y,
                          unsigned int width,
                          unsigned int height,
                          unsigned long plane_mask,
                          Bool keep_cache,
                          unsigned int compression );

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • rgb β€” source Pixmap for red, green and blue channels
  • a β€” source Pixmap for the alpha channel
  • x, y, width, height β€” rectangle on Pixmap to be encoded into ASImage.
  • plane_mask β€” limits color planes to be copied from Pixmap.
  • keep_cache β€” indicates if we should keep XImage, used to copy image data from the X server, and attached it to ximage member of resulting ASImage.
  • compression β€” degree of compression of resulting ASImage.

πŸ“ RETURN VALUE πŸ“

pointer to newly allocated ASImage, containing encoded data, on success. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

picture2asimage will obtain XImage of the requested area of the X Pixmap. If alpha channel pixmap is supplied β€” it will be used to encode ASImage's alpha channel. Alpha channel pixmap must be either 8 or 1 bit deep, and it must have the same dimensions as main Pixmap. πŸ’…

not me stressing the rules again but: alpha pixmap = 8 or 1 bit deep AND same dimensions as the main Pixmap. that's the vibe check, bestie. βœ…

πŸ“ libAfterImage/asimage2ximage()

✨ NAME ✨ β€” asimage2ximage()

πŸŽ€ SYNOPSIS πŸŽ€

XImage  *asimage2ximage  (struct ASVisual *asv, ASImage *im);

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • im β€” source ASImage

πŸ“ RETURN VALUE πŸ“

On success returns newly created and encoded XImage of the same colordepth as the supplied ASVisual. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

asimage2ximage() creates new XImage of the exact same size as supplied ASImage, and depth of supplied ASVisual. Red, Green and Blue channels of ASImage then gets decoded, and encoded into XImage. Missing scanlines get filled with black color. πŸ–€

🌟 NOTES 🌟

Returned pointer to XImage will also be stored in im->alt.ximage, and It will be destroyed when XImage is destroyed, or reused in any subsequent calls to asimage2ximage(). If any other behaviour is desired β€” make sure you set im->alt.ximage to NULL, to dissociate XImage object from ASImage. ⚠️

the way this sneaky little pointer tucks itself into im->alt.ximage... if you want your own life, set it to NULL. periodt.

πŸ” SEE ALSO πŸ”

create_visual_ximage()


πŸ“ libAfterImage/asimage2alpha_ximage()

✨ NAME ✨ β€” asimage2alpha_ximage()

πŸŽ€ SYNOPSIS πŸŽ€

XImage  *asimage2alpha_ximage (struct ASVisual *asv,
                               ASImage *im, Bool bitmap);

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • im β€” source ASImage
  • bitmap β€” if True resulting XImage will have depth of 1 bit β€” traditional X mask; otherwise it will have depth of 8 (useful for XFree86 RENDER extension)

πŸ“ RETURN VALUE πŸ“

On success returns newly created and encoded XImage of the depth 1 or 8. NULL on failure.

πŸ’œ DESCRIPTION πŸ’œ

asimage2alpha_ximage() creates new XImage of the exact same size as supplied ASImage, and depth 1 or 8. Alpha channels of ASImage then gets decoded, and encoded into XImage. In case requested depth is 1 then alpha channel is interpreted like so: 127 or greater is encoded as 1, otherwise as 0. Missing scanlines get filled with 1s as they signify absence of mask. ✨

🌟 NOTES 🌟

Returned pointer to XImage will also be stored in im->alt.mask_ximage, and It will be destroyed when XImage is destroyed, or reused in any subsequent calls to asimage2mask_ximage(). If any other behaviour is desired β€” make sure you set im->alt.mask_ximage to NULL, to dissociate XImage object from ASImage. 🫢


πŸ“ libAfterImage/asimage2mask_ximage()

✨ NAME ✨ β€” asimage2mask_ximage()

same as asimage2alpha_ximage(). Supplied for convenience and compatibility with older versions. 🌸

πŸŽ€ SYNOPSIS πŸŽ€

XImage  *asimage2mask_ximage (struct ASVisual *asv, ASImage *im);

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • im β€” source ASImage

πŸ“ RETURN VALUE πŸ“

On success returns newly created and encoded XImage of the depth 1. NULL on failure.


πŸ“ libAfterImage/asimage2pixmap()

✨ NAME ✨ β€” asimage2pixmap()

πŸŽ€ SYNOPSIS πŸŽ€

Bool     asimage2drawable( struct ASVisual *asv, Drawable d, ASImage *im,
                           GC gc,
                           int src_x, int src_y, int dest_x, int dest_y,
                           unsigned int width, unsigned int height,
                           Bool use_cached);

🧚 INPUTS 🧚

  • asv β€” pointer to valid ASVisual structure
  • d β€” destination drawable β€” Pixmap or Window
  • im β€” source ASImage
  • gc β€” precreated GC to use for XImage transfer. If NULL, asimage2drawable() will use DefaultGC.
  • src_x β€” Specifies the offset in X from the left edge of the image defined by the ASImage structure.
  • src_y β€” Specifies the offset in Y from the top edge of the image defined by the ASImage structure.
  • dest_x,dest_y β€” Specify the x and y coordinates, which are relative to the origin of the drawable and are the coordinates of the subimage.
  • width,height β€” Specify the width and height of the subimage, which define the dimensions of the rectangle.
  • use_cached β€” If True will make asimage2pixmap() to use XImage attached to ASImage, instead of creating new one. Only works if ASImage->ximage data member is not NULL.

πŸ“ RETURN VALUE πŸ“

On success returns True.

πŸ’œ DESCRIPTION πŸ’œ

asimage2drawable() creates will copy portion of ASImage onto the X Drawable. It checks if it needs to encode XImage from ASImage data, and calls asimage2ximage() if yes, it has to. It then supplied gc or DefaultGC of the screen to transfer XImage to the server. Missing scanlines get filled with black color. πŸ‘‘

πŸ” SEE ALSO πŸ”

asimage2ximage() asimage2pixmap() create_visual_pixmap()


πŸ“ libAfterImage/asimage2pixmap()

✨ NAME ✨ β€” asimage2pixmap()

πŸŽ€ SYNOPSIS πŸŽ€

Pixmap   asimage2pixmap  ( struct ASVisual *asv, Window root,
                           ASImage *im, GC gc, Bool use_cached);

✨ INPUTS ✨

okay so here's the lil shopping list of what you gotta hand over, no substitutions bestie πŸ’…

  • asv β€” pointer to a valid ASVisual structure 🫢
  • root β€” root window of the destination screen 🌸
  • im β€” the source ASImage (the pic in question, the moment itself) πŸ’–
  • gc β€” a precreated GC to use for the XImage transfer. If it's NULL, asimage2pixmap() will just use DefaultGC instead. no biggie ✨
  • use_cached β€” if True, this makes asimage2pixmap() use the XImage attached to the ASImage instead of making a brand new one. ⚠️ it only works if the ASImage->ximage data member is not NULL β€” so like, check first, don't just yolo it πŸ™ˆ

πŸ’« RETURN VALUE πŸ’«

slay on success, it hands you back a newly pixmap with the exact same colordepth as ASVisual. πŸ‘‘

and on failure? None. literally nothing. the void. πŸ’€


🌈 DESCRIPTION 🌈

okay so asimage2pixmap() makes a new pixmap that's exactly the same size as the ASImage you gave it. then it calls asimage2drawable to copy the entire content of the ASImage onto that freshly created pixmap. whole thing. every pixel. no crumbs left behind. ✨


πŸŽ€ EXAMPLE πŸŽ€

live footage of it being used irl:

asview.c: ASView.5

πŸ¦‹ SEE ALSO πŸ¦‹

go read these too, i'm obsessed with them fr fr:

  • asimage2ximage()
  • asimage2drawable()
  • create_visual_pixmap()
  • libAfterImage/asimage2mask()

πŸ‘‘ NAME asimage2mask() πŸ‘‘

πŸ“œ SYNOPSIS πŸ“œ

Pixmap   asimage2mask ( struct ASVisual *asv, Window root,
                        ASImage *im, GC gc, Bool use_cached);

πŸ’– the arg breakdown πŸ’–

  • asv β€” pointer to a valid ASVisual structure
  • root β€” root window of the destination screen
  • im β€” source ASImage
  • gc β€” a precreated GC for 1 bit deep drawables, used for the XImage transfer. If it's NULL, asimage2mask() will create one itself. girlboss behaviour πŸ’…
  • use_cached β€” if True, asimage2mask() will use the mask XImage attached to the ASImage instead of creating a new one. ⚠️ only works if the ASImage->alt.mask_ximage data member is not NULL.

⭐ RETURN VALUE ⭐

on success you get a newly created pixmap with the colordepth 1. yes queen, one bit and thriving. πŸ‘‘

on failure: None. that's it. that's the whole story. 😭


🌸 DESCRIPTION 🌸

so asimage2mask() creates a new pixmap that is exactly the same size as the ASImage you supplied. then it calls asimage2mask_ximage(). ✨

after that it takes the gc you gave it β€” or makes a new gc if you didn't β€” and uses it to transfer the XImage over to the server and put it onto the Pixmap. πŸššπŸ’¨

oh and heads up: missing scanlines get filled with 1s. that's just how it do. no cap. 🩹


πŸ”₯ SEE ALSO πŸ”₯

  • asimage2mask_ximage()

<div align="center">this masterpiece comes to you from the 3rd Berkeley Distribution, riding with AfterStep v.2.2.12, and it's the ximage(3x) page you just read every last crumb of. go forth and mask, bestie πŸ«ΆπŸ’œπŸ§šβ€β™€οΈ</div>

πŸ“¦ where this page comes from