Preface Introduction API Topic index API Glossary F.A.Q. Copyright
|AFTERImage||overview of libAfterImage image library|
- generic imaging library originally designed for
AfterStep X Window Manager.
libAfterImage is the imaging library implemented for AfterStep
X Window Manager. It has been generalized to be suitable for any
application in need of robust graphics engine.
It provides facilities for loading images from files of different
formats, compressed in memory storage of images, scaling,
tinting/shading, flipping and superimposition of arbitrary number of
images over each other. In addition it allows for linear gradients
drawing, and antialiased/smoothed text drawing using both FreeType
library and X Window fonts.
Primary goals of this library are to achieve exceptional quality of
images and text , making code fast and small at the same time.
Additional steps are taken to compensate for screen colordepth
limitation, and different error diffusion algorithms are used to
provide for smooth images even in low colordepth modes.
libAfterImage has been implemented as an attempt to address several
issues. First one, and most important is that X Window System
completely lacks any tools for image manipulation, except for very
rudimentary operations. With Introduction of Render extentions in
XFree86 4.0 that situation is changing, but still is far from
perfect. There need is therefore to implement client side image
manipulation. That inturn creates a problem of image data transfer
between Server and client.
To avoid that full-time image storage on the client side is needed.
Which is memory extensive. So there appears to be a need for some
On the other side there is an image quality issue. Its easy to write
a scaling function by simply dropping out or duplicating pixels,
but quality is awfull. What is needed is very fast
averaging/interpolation code. That brings us to the issue of 8 bits
per channel. Add two pixels together and you get overflow. So all the
math has to be performed in different colorspace and then converted
back. On the other side, such a conversion may discard valuable bits,
so some compensation method has to be implemented.
On the text drawing side of things, there are numerous problems just
as well. Native X fonts look ugly as soon as you try to show any
decently sized text . That is supposed to be solved with said Render
extensions to XFree86, but as experiense has shown, things aren't as
easy as it looks, besides one wants his app to run well under any X
Server. FreeType library provides a solution, but not always
available. Another problem is that if you keep all your images on the
client side, you want to draw text on client side as well.
The solution is to provide transparent interface that could use both
X fonts and FreeType, cache glyphs on the client side and possibly
perform smoothing of ugly X fonts.
There is no library solving all this problems in one fell swoop,
except for monstrous ones, like ImLib.
Hence libAfterImage has come to life.
libAfterStep provides sevarl facilities.
1. X Visual abstruction layer via ASVisual . This layer handles color
management, transfer of data to and from X Server, and other screen
2. Scanline handling facility via ASScanline . ASScanline is the most
widely used structure since image handling is implemented on
3. Image storage, trasformation and rendering via ASImage . ASImage
provides for generic container used for any image or text
manipulation. It incorporates such a robust facilities as in-memory
RLE compression, separate channel storage of 4 channels ( Alpha, Red,
Green, and Blue ) with 8 bit per channel.
4. Simplified font handling facility via ASFont and ASFointManager.
All the font handling is done using ASFont structure, no matter what
type of font is used. Any font supported by X11 and FreeType can be
5. Transparent image file reading for many different formats. Included
built-in XPM reading code and XCF ( GIMP's native format ).
via external libraries :
XPM, JPEG, PNG, TIFF, GIF
via built in code :
XPM, XCF, PNM, PPM, BMP, ICO, CUR
Note that XPM can be supported both via built-in code or via libXpm,
depending on compilation configuration.
Actuall image file format is autodetected from the file contents -
file name extention is not used and can be anything at all.
6. Image export into many popular file formats. Currently implemented :
XPM, JPEG, PNG, GIF. Work is underway to implement support for TIFF,
XCF, BMP, ICO.
7. Image quantization to arbitrary size colormap .
8. libAfterImage could be used without X window system, which is
coninient for such thing as web development. XML Image manipulation
tool, that could be used in such activity is included (see ascompose .c)
9. Image reference counting
libAfterBase - AfterStep basic functionality library. That Includes
Hash tables, file search methods, message output, generic types.
However effort has been made to allow for standalone configuration as
well. If libAfterBase is not found at compilation time - libAfterImage
will use extract from libAfterBase included with libAfterImage .
Implement support for Targa and PCX image format and maybe some other
formats as well.
Implement complete support for I18N internationalization.
Implement color <->pixel conversion for all colordepths.
Sasha Vasko <sasha at aftercode dot net>
ASView - image loading from the file and displaying in window.
ASScale - image loading from file and scaling to arbitrary size.
ASTile - image loading from file, tiling and tinting to arbitrary
size and color .
ASMerge - imgae loading and merging with another image.
ASGrad - mutlipoint gradient drawing.
ASFlip - image loading from file and rotation.
ASText - trexturized semitransparent antialised text drawing.
ascmap .h asfont .h asimage .h asvisual .h blender .h export .h
import .h transform .h ximage .h
ASVisual initialization :
ASVisual encoding/decoding :
ASVisual convenience functions :
Colorspace conversion :
rgb2value(), rgb2saturation(), rgb2hue(), rgb2luminance(),
rgb2hsv(), rgb2hls(), hsv2rgb(), hls2rgb(),
degrees2hue16(), hue162degrees(), normalize_degrees_val()
Image quantization :
merge_scanline methods :
tint_scanlines(), add_scanlines(), sub_scanlines(),
diff_scanlines(), darken_scanlines(), lighten_scanlines(),
screen_scanlines(), overlay_scanlines(), hue_scanlines(),
ASImage handling :
asimage_init(), asimage_start(), create_asimage(),
ASImage channel data manipulations :
ImageManager Reference counting and managing :
store_asimage(), fetch_asimage(), dup_asimage(),
Layers helper functions :
asimage_decode_line (), set_decoder_shift(),
ASImage from scientific data :
X11 conversions :
ximage2asimage(), pixmap2asimage(), asimage2ximage(),
asimage2mask_ximage(), asimage2pixmap(), asimage2mask()
scale_asimage(), tile_asimage(), merge_layers(),
flip_asimage(), mirror_asimage(), pad_asimage(),
blur_asimage_gauss(), fill_asimage(), adjust_asimage_hsv()
Text Drawing :
open_freetype_font(), open_X11_font(), get_asfont(),
release_font(), print_asfont(), print_asglyph(),
AfterStep Documentation - October 2005 ( 80% complete )