asvisual - abstraction layer on top of X Visuals, focusing on color handling libAfterImage/asvisual.h
Contents
Description
create_visual_ximage() will perform sanity checks on passed parameters, and it will attempt to create
XImage of sufficient size, and specified colordepth. It will also setup hooks for XImage deallocation to
be handled by custom function.
3rd Berkeley Distribution AfterStep v.2.2.12 asvisual(3x)
Example
asview.c: ASView.2
libAfterImage/visual2visual_prop()
Function
Ids of the channels. These are basically synonyms to related ARGB32 channel numbers
Inputs
asv - pointer to the valid ASVisual structure.
width, height - size of the XImage to create.
depth - depth of the XImage to create. If 0 asv->true_depth will be used.
Name
asvisual - abstraction layer on top of X Visuals, focusing on color handling libAfterImage/asvisual.h
Nameargb32
- main color datatype
Nameargb32_Manhattan_Distance()
- This function can be used to evaluate closeness of two colors.
Nameasvisual
- an abstraction layer on top of X Server Visual.
Namecolorpair
- convenient structure to hold pair of colors.
Namecreate_Asvisual()
Namecreate_Asvisual_For_Id()
Namecreate_Visual_Gc()
Namecreate_Visual_Pixmap()
Namecreate_Visual_Window()
Namecreate_Visual_Ximage()
Namedestroy_Asvisual()
Nameic_Red
- red channel IC_GREEN - green channel IC_BLUE - blue channel IC_ALPHA - alpha channel IC_NUM_CHANNELS -
number of supported channels
Namequery_Screen_Visual_Id()
query_screen_visual()
Namesetup_As_Colormap()
Namesetup_Pseudo_Visual()
Namesetup_Truecolor_Visual()
Namevisual2Visual_Prop()
Namevisual_Prop2Visual()
Return Value
pointer to newly created XImage on success. NULL on failure.
See Also
Structures:
ColorPair
ASVisual
Functions :
ASVisual initialization :
query_screen_visual(), setup_truecolor_visual(),
setup_pseudo_visual(), setup_as_colormap(),create_asvisual(),
destroy_asvisual()
ASVisual encoding/decoding :
visual2visual_prop(), visual_prop2visual()
ASVisual convenience functions :
create_visual_window(), create_visual_pixmap(),
create_visual_ximage()
Other libAfterImage modules :
ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
import.h transform.h ximage.h
Source
typedef struct ASVisual {
Display *dpy;
/* This envvar will be used to determine what X Visual
* (in hex) to use. If unset then best possible will
* be selected automagically : */ #define ASVISUAL_ID_ENVVAR "AFTERIMAGE_VISUAL_ID"
XVisualInfo visual_info;
/* this things are calculated based on Visual : */
unsigned long rshift, gshift, bshift;
unsigned long rbits, gbits, bbits;
unsigned long true_depth; /* could be 15 when X reports 16 */
Bool BGR_mode;
Bool msb_first;
/* we must have colormap so that we can safely create windows
* with different visuals even if we are in TrueColor mode : */
Colormap colormap;
Bool own_colormap; /* tells us to free colormap when we
* done */
unsigned long black_pixel, white_pixel;
/* for PseudoColor mode we need some more stuff : */
enum {
ACM_None = 0,
ACM_3BPP,
ACM_6BPP,
ACM_12BPP
} as_colormap_type ; /* there can only be 64 or 4096 entries
* so far ( 6 or 12 bpp) */
unsigned long *as_colormap; /* array of preallocated colors for
* PseudoColor mode */
union /* reverse color lookup tables : */
{
ARGB32 *xref;
struct ASHashTable *hash;
}as_colormap_reverse ;
/* different useful callbacks : */
CARD32 (*color2pixel_func) ( struct ASVisual *asv,
CARD32 encoded_color,
unsigned long *pixel);
void (*pixel2color_func) ( struct ASVisual *asv,
unsigned long pixel,
CARD32 *red, CARD32 *green,
CARD32 *blue);
void (*ximage2scanline_func)( struct ASVisual *asv,
XImage *xim,
struct ASScanline *sl, int y,
unsigned char *xim_data );
void (*scanline2ximage_func)( struct ASVisual *asv,
XImage *xim,
struct ASScanline *sl, int y,
unsigned char *xim_data );
#define ASGLX_Unavailable 0 #define ASGLX_Available (0x01<<0) #define
ASGLX_DoubleBuffer (0x01<<1) #define ASGLX_RGBA (0x01<<2) #define
ASGLX_UseForImageTx (0x01<<3)
ASFlagType glx_support ; /* one of the above flags */
void *glx_scratch_gc_indirect ; /* (GLXContext) */
void *glx_scratch_gc_direct ; /* (GLXContext) */
Window scratch_window;
#ifndef X_DISPLAY_MISSING #define ARGB2PIXEL(asv,argb,pixel) \
(asv)->color2pixel_func((asv),(argb),(pixel)) #define GET_SCANLINE(asv,xim,sl,y,xim_data) \
(asv)->ximage2scanline_func((asv),(xim),(sl),(y),(xim_data)) #define
PUT_SCANLINE(asv,xim,sl,y,xim_data) \
(asv)->scanline2ximage_func((asv),(xim),(sl),(y),(xim_data)) #else #define
ARGB2PIXEL(asv,argb,pixel) \
do{ break; }while(0) #define GET_SCANLINE(asv,xim,sl,y,xim_data) \
do{ break; }while(0) #define PUT_SCANLINE(asv,xim,sl,y,xim_data) \
do{ break; }while(0) #endif }ASVisual;
libAfterImage/query_screen_visual()
Synopsis
XImage* create_visual_ximage( ASVisual *asv,
unsigned int width, unsigned int height,
unsigned int depth );
