asimage.h

Go to the documentation of this file.
00001 #ifndef ASIMAGE_HEADER_FILE_INCLUDED
00002 #define ASIMAGE_HEADER_FILE_INCLUDED
00003 
00004 #include "asvisual.h"
00005 #include "blender.h"
00006 #include "asstorage.h"
00007 #undef TRACK_ASIMAGES
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 struct ASImageBevel;
00013 struct ASImageDecoder;
00014 struct ASImageOutput;
00015 struct ASScanline;
00016 
00017 /****h* libAfterImage/asimage.h
00018  * NAME
00019  * asimage defines main structures and function for image manipulation.
00020  * DESCRIPTION
00021  * libAfterImage provides powerful functionality to load, store
00022  * and transform images. It allows for smaller memory utilization by
00023  * utilizing run-length encoding of the image data. There could be
00024  * different levels of compression selected, allowing to choose best
00025  * speed/memory ratio.
00026  *
00027  * SEE ALSO
00028  * Structures :
00029  *          ASImage
00030  *          ASImageManager
00031  *          ASImageBevel
00032  *          ASImageDecoder
00033  *          ASImageOutput
00034  *          ASImageLayer
00035  *          ASGradient
00036  *
00037  * Functions :
00038  *          asimage_init(), asimage_start(), create_asimage(),
00039  *          clone_asimage(), destroy_asimage()
00040  *
00041  *   ImageManager Reference counting and managing :
00042  *          create_image_manager(), destroy_image_manager(),
00043  *          store_asimage(), fetch_asimage(), query_asimage(),
00044  *          dup_asimage(), release_asimage(),
00045  *          release_asimage_by_name(), forget_asimage(),
00046  *          safe_asimage_destroy()
00047  *
00048  *   Gradients helper functions :
00049  *          flip_gradient(), destroy_asgradient()
00050  *
00051  *   Layers helper functions :
00052  *          init_image_layers(), create_image_layers(),
00053  *          destroy_image_layers()
00054  *
00055  *   Encoding :
00056  *          asimage_add_line(), asimage_add_line_mono(),
00057  *          asimage_print_line(), get_asimage_chanmask(),
00058  *          move_asimage_channel(), copy_asimage_channel(),
00059  *          copy_asimage_lines()
00060  *
00061  *   Decoding
00062  *          start_image_decoding(), stop_image_decoding(),
00063  *          asimage_decode_line (), set_decoder_shift(),
00064  *          set_decoder_back_color()
00065  *
00066  *   Output :
00067  *          start_image_output(), set_image_output_back_color(),
00068  *          toggle_image_output_direction(), stop_image_output()
00069  *
00070  * Other libAfterImage modules :
00071  *          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
00072  *          import.h transform.h ximage.h
00073  * AUTHOR
00074  * Sasha Vasko <sasha at aftercode dot net>
00075  ******/
00076 
00077 #define ASIMAGE_PATH_ENVVAR             "IMAGE_PATH"
00078 #define ASFONT_PATH_ENVVAR              "FONT_PATH"
00079 
00080 /****d* libAfterImage/ASAltImFormats
00081  * NAME 
00082  * ASAltImFormats identifies what output format should be used for storing 
00083  * the transformation result. Also identifies what data is currently stored
00084  * in alt member of ASImage structure.
00085  * SOURCE
00086  */
00087 typedef enum {
00088         ASA_ASImage = 0,
00089     ASA_XImage,
00090         ASA_MaskXImage,
00091         /* temporary XImages to be allocated from static pool of memory :*/
00092     ASA_ScratchXImage,  
00093         ASA_ScratchMaskXImage,
00094         
00095         ASA_ScratchXImageAndAlpha,
00096 
00097         ASA_ARGB32,
00098         ASA_Vector,       /* This cannot be used for transformation's result
00099                                            * format */
00100         ASA_Formats
00101 }ASAltImFormats;
00102 /*******/
00103 /****s* libAfterImage/ASImage
00104  * NAME
00105  * ASImage is the main structure to hold image data.
00106  * DESCRIPTION
00107  * Images are stored internally split into ARGB channels, each split
00108  * into scanline. Actuall data is stored using ASStorage container. Inside
00109  * ASImage data structure we only store IDs pointing to data in ASStorage
00110  * ASStorage implements reference counting, data compression, 
00111  * automatic memory defragmentation and other nice things.
00112  * SEE ALSO
00113  *  asimage_init()
00114  *  asimage_start()
00115  *  create_asimage()
00116  *  destroy_asimage()
00117  * SOURCE
00118  */
00119 
00120 struct ASImageAlternative;
00121 struct ASImageManager;
00122 
00123 /* magic number identifying ASFont data structure */
00124 #define MAGIC_ASIMAGE            0xA3A314AE
00125 
00126 typedef struct ASImage
00127 {
00128 
00129   unsigned long magic ;
00130 
00131   unsigned int width, height;       /* size of the image in pixels */
00132 
00133   /* arrays of storage ids of stored scanlines of particular channel: */
00134   ASStorageID *alpha,
00135                           *red,
00136                           *green,
00137                           *blue;
00138   
00139   ASStorageID *channels[IC_NUM_CHANNELS]; 
00140                                                                         /* merely a shortcut so we can
00141                                                                          * somewhat simplify code in loops */
00142 
00143   ARGB32 back_color ;               /* background color of the image, so
00144                                                                          * we could discard everything that
00145                                                                          * matches it, and then restore it
00146                                                                          * back. */
00147 
00148   struct ASImageAlternative
00149   {  /* alternative forms of ASImage storage : */
00150         XImage *ximage ;                /* pointer to XImage created as the
00151                                                                          * result of transformations whenever
00152                                                                          * we request it to output into
00153                                                                          * XImage ( see to_xim parameter ) */
00154         XImage *mask_ximage ;           /* XImage of depth 1 that could be
00155                                                                          * used to store mask of the image */
00156         ARGB32 *argb32 ;                /* array of widthxheight ARGB32
00157                                                                          * values */
00158         double *vector ;                            /* scientific data that should be used
00159                                                                          * in conjunction with
00160                                                                          * ASScientificPalette to produce
00161                                                                          * actuall ARGB data */
00162   }alt;
00163 
00164   struct ASImageManager *imageman;  /* if not null - then image could be
00165                                                                          * referenced by some other code */
00166   int                    ref_count ;/* this will tell us what us how many
00167                                                                          * times */
00168 
00169         
00170   char                  *name ;     /* readonly copy of image name 
00171                                                                          * this name is a hash value used to 
00172                                                                          * store image in the image-man's hash,
00173                                                                          * and gets freed automagically on image 
00174                                                                          * removal from hash */
00175 
00176 #define ASIM_DATA_NOT_USEFUL    (0x01<<0)
00177 #define ASIM_VECTOR_TOP2BOTTOM  (0x01<<1)
00178 #define ASIM_XIMAGE_8BIT_MASK   (0x01<<2)
00179 #define ASIM_NO_COMPRESSION             (0x01<<3) /* Do not use compression to 
00180                                                                                    * save some computation time
00181                                                                                    */
00182 #define ASIM_ALPHA_IS_BITMAP    (0x01<<4) 
00183 #define ASIM_RGB_IS_BITMAP              (0x01<<5) 
00184 #define ASIM_XIMAGE_NOT_USEFUL  (0x01<<6)
00185 #define ASIM_NAME_IS_FILENAME   (0x01<<7)
00186 
00187   ASFlagType                     flags ;    /* combination of the above flags */
00188   
00189 } ASImage;
00190 /*******/
00191 
00192 /****d* libAfterImage/LIMITS
00193  * NAME
00194  * MAX_IMPORT_IMAGE_SIZE        effectively limits size of the allowed
00195  *                                                      images to be loaded from files. That is
00196  *                                                      needed to be able to filter out corrupt files.
00197  * NAME
00198  * MAX_BEVEL_OUTLINE            Limit on bevel outline to be drawn around
00199  *                                                      the image.
00200  * NAME
00201  * MAX_SEARCH_PATHS             Number of search paths to be used while loading 
00202  *                                                      images from files.
00203  */
00204 #define MAX_IMPORT_IMAGE_SIZE   8000
00205 #define MAX_BEVEL_OUTLINE               100
00206 #define MAX_SEARCH_PATHS                8      /* prudently limiting ourselfs */
00207 /******/
00208 
00209 /****s* libAfterImage/ASImageManager
00210  * NAME
00211  * ASImageManager structure to be used to maintain list of loaded images 
00212  * for given set of search paths and gamma. Images are named and reference 
00213  * counted.
00214  * SOURCE
00215  */
00216 typedef struct ASImageManager
00217 {
00218         ASHashTable  *image_hash ;
00219         /* misc stuff that may come handy : */
00220         char         *search_path[MAX_SEARCH_PATHS+1];
00221         double            gamma ;
00222 }ASImageManager;
00223 /*************/
00224 
00225 
00226 /* Auxiliary data structures : */
00227 /****s* libAfterImage/ASVectorPalette
00228  * NAME
00229  * ASVectorPalette contains pallette allowing us to map double values 
00230  * in vector image data into actuall ARGB values.
00231  * SOURCE
00232  */
00233 typedef struct ASVectorPalette
00234 {
00235         unsigned int npoints ;
00236         double *points ;
00237         CARD16 *channels[IC_NUM_CHANNELS] ;   /* ARGB data for key points. */
00238         ARGB32  default_color;
00239 }ASVectorPalette;
00240 /*************/
00241 
00242 /****s* libAfterImage/asimage/ASImageLayer
00243  * NAME
00244  * ASImageLayer specifies parameters of the image superimposition.
00245  * DESCRIPTION
00246  * libAfterImage allows for simultaneous superimposition (overlaying) of
00247  * arbitrary number of images. To facilitate this ASImageLayer structure
00248  * has been created in order to specify parameters of each image
00249  * participating in overlaying operation. Images need not to be exact
00250  * same size. For each image its position on destination is specified
00251  * via dst_x and dst_y data members. Each image maybe tiled and clipped
00252  * to fit into rectangle specified by clip_x, clip_y, clip_width,
00253  * clip_height ( in image coordinates - not destination ). If image is
00254  * missing, then area specified by dst_x, dst_y, clip_width, clip_height
00255  * will be filled with solid_color.
00256  * Entire image will be tinted using tint parameter prior to overlaying.
00257  * Bevel specified by bevel member will be drawn over image prior to
00258  * overlaying. Specific overlay method has to be specified.
00259  * merge_scanlines method is pointer to a function,
00260  * that accepts 2 ASScanlines as arguments and performs overlaying of
00261  * first one with the second one.
00262  * There are 15 different merge_scanline methods implemented in
00263  * libAfterImage, including alpha-blending, tinting, averaging,
00264  * HSV and HSL colorspace operations, etc.
00265  * NOTES
00266  * ASImageLayer s could be organized into chains using next pointers.
00267  * Since there could be a need to rearrange layers and maybe bypass some
00268  * layers - we need to provide for flexibility, while at the same time
00269  * allowing for simplicity of arrays. As the result next pointers could
00270  * be used to link together continuous arrays of layer, like so :
00271  * array1: [layer1(next==NULL)][layer2(next!=NULL)]
00272  *          ____________________________|
00273  *          V
00274  * array2: [layer3(next==NULL)][layer4(next==NULL)][layer5(next!=NULL)]
00275  *          ________________________________________________|
00276  *          V
00277  * array3: [layer6(next==NULL)][layer7(next==layer7)]
00278  *                                ^______|
00279  *
00280  * While iterating throught such a list we check for two conditions -
00281  * exceeding count of layers and layer pointing to self. When any of
00282  * that is met - we stopping iteration.
00283  * SEE ALSO
00284  * merge_layers()
00285  * blender.h
00286  * SOURCE
00287  */
00288 
00289 typedef struct ASImageLayer
00290 {
00291         ASImage *im;
00292         ARGB32   solid_color ;              /* If im == NULL, then fill
00293                                                                                  * the area with this color. */
00294 
00295         int dst_x, dst_y;                                       /* placement in overall
00296                                                                                  * composition */
00297 
00298         /* clip area could be partially outside of the image -
00299          * image gets tiled in it */
00300         int clip_x, clip_y;
00301         unsigned int clip_width, clip_height;
00302 
00303         ARGB32 tint ;                           /* if 0 - no tint */
00304         struct ASImageBevel *bevel ;            /* border to wrap layer with
00305                                                                                  * (for buttons, etc.)*/
00306 
00307         /* if image is clipped then we need to specify offsets of bevel as
00308          * related to clipped rectangle. Normally it should be :
00309          * 0, 0, im->width, im->height. And if width/height left 0 - it will
00310          * default to this values. Note that clipped image MUST be entirely
00311          * inside the bevel rectangle. !!!*/
00312         int bevel_x, bevel_y;
00313         unsigned int bevel_width, bevel_height;
00314 
00315         int merge_mode ;                        /* reserved for future use */
00316         merge_scanlines_func merge_scanlines ;  /* overlay method */
00317         struct ASImageLayer *next;              /* optional pointer to next
00318                                                                                          * layer. If it points to
00319                                                                                          * itself - then end of the
00320                                                                                          * chain.*/
00321         void *data;                             /* hook to hung data on */
00322 }ASImageLayer;
00323 /********/
00324 
00325 /****d* libAfterImage/asimage/GRADIENT_TYPE_flags
00326  * FUNCTION
00327  * Combination of this flags defines the way gradient is rendered.
00328  * NAME
00329  * GRADIENT_TYPE_DIAG when set it will cause gradient's direction to be 
00330  * rotated by 45 degrees
00331  * NAME
00332  * GRADIENT_TYPE_ORIENTATION will cause gradient direction to be rotated 
00333  * by 90 degrees. When combined with GRADIENT_TYPE_DIAG - rotates gradient 
00334  * direction by 135 degrees.
00335  * SOURCE
00336  */
00337 #define GRADIENT_TYPE_DIAG          (0x01<<0)
00338 #define GRADIENT_TYPE_ORIENTATION   (0x01<<1)
00339 #define GRADIENT_TYPE_MASK          (GRADIENT_TYPE_ORIENTATION| \
00340                                                                          GRADIENT_TYPE_DIAG)
00341 /********/
00342 
00343 /****d* libAfterImage/asimage/GRADIENT_TYPE
00344  * FUNCTION
00345  * This are named combinations of above flags to define type of gradient.
00346  * NAME 
00347  * GRADIENT_Left2Right normal left-to-right gradient.
00348  * NAME 
00349  * GRADIENT_TopLeft2BottomRight diagonal top-left to bottom-right.
00350  * NAME 
00351  * GRADIENT_Top2Bottom vertical top to bottom gradient.
00352  * NAME 
00353  * GRADIENT_BottomLeft2TopRight diagonal bottom-left to top-right.
00354  * SOURCE
00355  */
00356 #define GRADIENT_Left2Right                     0
00357 #define GRADIENT_TopLeft2BottomRight    GRADIENT_TYPE_DIAG
00358 #define GRADIENT_Top2Bottom                             GRADIENT_TYPE_ORIENTATION
00359 #define GRADIENT_BottomLeft2TopRight    (GRADIENT_TYPE_DIAG| \
00360                                                                                  GRADIENT_TYPE_ORIENTATION)
00361 /********/
00362 
00363 /****s* libAfterImage/ASGradient
00364  * NAME
00365  * ASGradient describes how gradient is to be drawn.
00366  * DESCRIPTION
00367  * libAfterImage includes functionality to draw multipoint gradients in
00368  * 4 different directions left->right, top->bottom and diagonal
00369  * lefttop->rightbottom and bottomleft->topright. Each gradient described
00370  * by type, number of colors (or anchor points), ARGB values for each
00371  * color and offsets of each point from the beginning of gradient in
00372  * fractions of entire length. There should be at least 2 anchor points.
00373  * very first point should have offset of 0. and last point should have
00374  * offset of 1. Gradients are drawn in ARGB colorspace, so it is possible
00375  * to have semitransparent gradients.
00376  * SEE ALSO
00377  * make_gradient()
00378  * SOURCE
00379  */
00380 
00381 typedef struct ASGradient
00382 {
00383         int                     type;     /* see GRADIENT_TYPE above */
00384         
00385         int         npoints;  /* number of anchor points */
00386         ARGB32     *color;    /* ARGB color values for each anchor point*/
00387         double     *offset;   /* offset of each point from the beginning in
00388                                                    * fractions of entire length */
00389 }ASGradient;
00390 /********/
00391 
00392 /****d* libAfterImage/asimage/flip
00393  * FUNCTION
00394  * This are flags that define rotation angle.
00395  * NAME
00396  * FLIP_VERTICAL defines rotation of 90 degrees counterclockwise.
00397  * NAME
00398  * FLIP_UPSIDEDOWN defines rotation of 180 degrees counterclockwise.
00399  * combined they define rotation of 270 degrees counterclockwise.
00400  * SOURCE
00401  */
00402 #define FLIP_VERTICAL       (0x01<<0)
00403 #define FLIP_UPSIDEDOWN         (0x01<<1)
00404 #define FLIP_MASK                       (FLIP_UPSIDEDOWN|FLIP_VERTICAL)
00405 /********/
00406 /****d* libAfterImage/asimage/tint
00407  * FUNCTION
00408  * We use 32 bit ARGB values to define how tinting should be done.
00409  * The formula for tinting particular channel data goes like that:
00410  * tinted_data = (image_data * tint)/128
00411  * So if tint channel value is greater then 127 - same channel will be
00412  * brighter in destination image; if it is lower then 127 - same channel
00413  * will be darker in destination image. Tint channel value of 127
00414  * ( or 0x7F hex ) does not change anything.
00415  * Alpha channel is tinted as well, allowing for creation of
00416  * semitransparent images. Calculations are performed in 24.8 format -
00417  * with 8 bit precision. Result is saturated to avoid overflow, and
00418  * precision is carried over to next pixel ( error diffusion ), when con
00419  * verting 24.8 to 8 bit format.
00420  * NAME
00421  * TINT_NONE special value that disables tinting
00422  * NAME
00423  * TINT_LEAVE_SAME also disables tinting.
00424  * SOURCE
00425  */
00426 #define TINT_NONE                       0
00427 #define TINT_LEAVE_SAME     (0x7F7F7F7F)
00428 #define TINT_HALF_DARKER        (0x3F3F3F3F)
00429 #define TINT_HALF_BRIGHTER      (0xCFCFCFCF)
00430 #define TINT_RED                        (0x7F7F0000)
00431 #define TINT_GREEN                      (0x7F007F00)
00432 #define TINT_BLUE                       (0x7F00007F)
00433 /********/
00434 /****d* libAfterImage/asimage/compression
00435  * FUNCTION
00436  * Defines the level of compression to attempt on ASImage scanlines.
00437  * NAME 
00438  * ASIM_COMPRESSION_NONE defined as 0 - disables compression.
00439  * NAME 
00440  * ASIM_COMPRESSION_FULL defined as 100 - highest compression level.
00441  * Anything in between 0 and 100 will cause only part of the scanline to 
00442  * be compressed. 
00443  * This is obsolete. Now all images are compressed if possible.
00444  ********/
00445 #define ASIM_COMPRESSION_NONE       0
00446 #define ASIM_COMPRESSION_FULL      100
00447 
00448 extern Bool asimage_use_mmx ;
00449 
00450 /****f* libAfterImage/asimage/asimage_init()
00451  * NAME 
00452  * asimage_init() frees datamembers of the supplied ASImage structure, and
00453  *      initializes it to all 0.
00454  * SYNOPSIS
00455  * void asimage_init (ASImage * im, Bool free_resources);
00456  * INPUTS
00457  * im             - pointer to valid ASImage structure
00458  * free_resources - if True will make function attempt to free
00459  *                  all non-NULL pointers.
00460  *********/
00461 /****f* libAfterImage/asimage/flush_asimage_cache()
00462  * NAME
00463  * flush_asimage_cache() destroys XImage and mask XImage kept from previous 
00464  * conversions to/from X Pixmap.
00465  * SYNOPSIS
00466  * void flush_asimage_cache (ASImage * im );
00467  * INPUTS
00468  * im             - pointer to valid ASImage structure
00469  *********/
00470 /****f* libAfterImage/asimage/asimage_start()
00471  * NAME
00472  * asimage_start() Allocates memory needed to store scanline of the image 
00473  * of supplied size. Assigns all the data members valid values. Makes sure 
00474  * that ASImage structure is ready to store image data.
00475  * SYNOPSIS
00476  * void asimage_start (ASImage * im, unsigned int width,
00477  *                                   unsigned int height,
00478  *                                   unsigned int compression);
00479  * INPUTS
00480  * im          - pointer to valid ASImage structure
00481  * width       - width of the image
00482  * height      - height of the image
00483  * compression - level of compression to perform on image data.
00484  *               compression has to be in range of 0-100 with 100
00485  *               signifying highest level of compression.
00486  * NOTES
00487  * In order to resize ASImage structure after asimage_start() has been
00488  * called, asimage_init() must be invoked to free all the memory, and
00489  * then asimage_start() has to be called with new dimensions.
00490  *********/
00491 /****f* libAfterImage/asimage/create_asimage()
00492  * NAME
00493  * create_asimage() Performs memory allocation for the new ASImage 
00494  * structure, as well as initialization of allocated structure based on 
00495  * supplied parameters.
00496  * SYNOPSIS
00497  * ASImage *create_asimage( unsigned int width,
00498  *                          unsigned int height,
00499  *                          unsigned int compression);
00500  * INPUTS
00501  * width       - desired image width
00502  * height      - desired image height
00503  * compression - compression level in new ASImage( see asimage_start()
00504  *               for more ).
00505  * RETURN VALUE
00506  * Pointer to newly allocated and initialized ASImage structure on
00507  * Success. NULL in case of any kind of error - that should never happen.
00508  *********/
00509 /****f* libAfterImage/asimage/clone_asimage()
00510  * NAME 
00511  * clone_asimage()
00512  * SYNOPSIS
00513  * ASImage *clone_asimage(ASImage *src, ASFlagType filter );
00514  * INPUTS
00515  * src      - original ASImage.
00516  * filter   - bitmask of channels to be copied from one image to another.
00517  * RETURN VALUE
00518  * New ASImage, as a copy of original image.
00519  * DESCRIPTION
00520  * Creates exact clone of the original ASImage, with same compression,
00521  * back_color and rest of the attributes. Only ASImage data will be
00522  * carried over. Any attached alternative forms of images (XImages, etc.)
00523  * will not be copied. Any channel with unset bit in filter will not be
00524  * copied. Image name, ASImageManager and ref_count will not be copied -
00525  * use store_asimage() afterwards and make sure you use different name,
00526  * to avoid clashes with original image.
00527  *********/
00528 /****f* libAfterImage/asimage/destroy_asimage()
00529  * NAME
00530  * destroy_asimage() frees all the memory allocated for specified ASImage. 
00531  * SYNOPSIS
00532  * void destroy_asimage( ASImage **im );
00533  * INPUTS
00534  * im                           - pointer to valid ASImage structure.
00535  * NOTES
00536  * If there was XImage attached to it - it will be deallocated as well.
00537  * EXAMPLE
00538  * asview.c: ASView.5
00539  *********/
00540 /****f* libAfterImage/asimage/asimage_replace()
00541  * NAME
00542  * asimage_replace() will replace ASImage's data using data from 
00543  * another ASImage
00544  * SYNOPSIS
00545  * Bool asimage_replace (ASImage *im, ASImage *from);
00546  * INPUTS
00547  * im                           - pointer to valid ASImage structure.
00548  * from                         - pointer to ASImage from which to take the data.
00549  * NOTES
00550  * this function updates image without reallocating structure itself, which 
00551  * means that all pointers to it will still be valid. If that function 
00552  * succeeds - [from] ASImage will become unusable and should be deallocated 
00553  * using free() call.
00554  *********/
00555 void asimage_init (ASImage * im, Bool free_resources);
00556 void flush_asimage_cache( ASImage *im );
00557 void asimage_start (ASImage * im, unsigned int width, unsigned int height, unsigned int compression);
00558 ASImage *create_asimage( unsigned int width, unsigned int height, unsigned int compression);
00559 ASImage *create_static_asimage( unsigned int width, unsigned int height, unsigned int compression);
00560 ASImage *clone_asimage( ASImage *src, ASFlagType filter );
00561 void destroy_asimage( ASImage **im );
00562 Bool asimage_replace (ASImage *im, ASImage *from);
00563 /****f* libAfterImage/asimage/set_asimage_vector()
00564  * NAME
00565  * set_asimage_vector() This function replaces contents of the vector 
00566  * member of ASImage structure with new double precision data.
00567  * SYNOPSIS
00568  * set_asimage_vector( ASImage *im, register double *vector );
00569  * INPUTS
00570  * im                           - pointer to valid ASImage structure.
00571  * vector           - scientific data to attach to the image.
00572  * NOTES
00573  * Data must have size of width*height ahere width and height are size of 
00574  * the ASImage.
00575  *********/
00576 Bool set_asimage_vector( ASImage *im, register double *vector );
00577 /****f* libAfterImage/asimage/vectorize_asimage()
00578  * NAME
00579  * vectorize_asimage() This function replaces contents of the vector 
00580  * member of ASImage structure with new double precision data, generated 
00581  * from native ARGB32 image contents. Color palette is generated by 
00582  * indexing color values using max_colors, dither and opaque_threshold 
00583  * parameters.
00584  * SYNOPSIS
00585  * ASVectorPalette* vectorize_asimage( ASImage *im, 
00586  *                                     unsigned int max_colors, 
00587  *                                     unsigned int dither,  
00588  *                                     int opaque_threshold );
00589  * INPUTS
00590  * im                           - pointer to valid ASImage structure.
00591  * max_colors       - maximum size of the colormap.
00592  * dither           - number of bits to strip off the color data ( 0...7 )
00593  * opaque_threshold - alpha channel threshold at which pixel should be
00594  *                    treated as opaque
00595  * RETURN VALUE
00596  * pointer to the ASVectorPalette structure that could be used for 
00597  * reverse conversion from double values to ARGB32. 
00598  * NOTES
00599  * alt.vector member of the supplied ASImage will be replaced and will 
00600  * contain WIDTHxHEIGHT double values representing generated scientific 
00601  * data.
00602  *********/
00603 ASVectorPalette* vectorize_asimage( ASImage *im, unsigned int max_colors, 
00604                                                 unsigned int dither,  int opaque_threshold );
00605 
00606 
00607 /****f* libAfterImage/asimage/create_image_manager()
00608  * NAME
00609  * create_image_manager()  create ASImage management and reference 
00610  * counting object.
00611  * SYNOPSIS
00612  * ASImageManager *create_image_manager( ASImageManager *reusable_memory,
00613  *                                       double gamma, ... );
00614  * INPUTS
00615  * reusable_memory - optional pointer to a block of memory to be used to
00616  *                   store ASImageManager object.
00617  * double gamma    - value of gamma correction to be used while loading
00618  *                   images from files.
00619  * ...             - NULL terminated list of up to 8 PATH strings to list
00620  *                   locations at which images could be found.
00621  * DESCRIPTION
00622  * Creates ASImageManager object in memory and initializes it with
00623  * requested gamma value and PATH list. This Object will contain a hash
00624  * table referencing all the loaded images. When such object is used while
00625  * loading images from the file - gamma and PATH values will be used, so
00626  * that all the loaded and referenced images will have same parameters.
00627  * File name will be used as the image name, and if same file is attempted
00628  * to be loaded again - instead reference will be incremented, and
00629  * previously loaded image will be retyrned. All the images stored in
00630  * ASImageManager's table will contain a back pointer to it, and they must
00631  * be deallocated only by calling release_asimage(). destroy_asimage() will
00632  * refuse to deallocate such an image.
00633  *********/
00634 /****f* libAfterImage/asimage/destroy_image_manager()
00635  * NAME 
00636  * destroy_image_manager() destroy management obejct.
00637  * SYNOPSIS
00638  * void destroy_image_manager( struct ASImageManager *imman, 
00639  *                                                         Bool reusable );
00640  * INPUTS
00641  * imman           - pointer to ASImageManager object to be deallocated
00642  * reusable        - if True, then memory that holds object itself will
00643  *                   not be deallocated. Usefull when object is created
00644  *                   on stack.
00645  * DESCRIPTION
00646  * Destroys all the referenced images, PATH values and if reusable is False,
00647  * also deallocates object's memory.
00648  *********/
00649 ASImageManager *create_image_manager( struct ASImageManager *reusable_memory, double gamma, ... );
00650 void     destroy_image_manager( struct ASImageManager *imman, Bool reusable );
00651 
00652 /****f* libAfterImage/asimage/store_asimage()
00653  * NAME
00654  * store_asimage()  add ASImage to the reference.
00655  * SYNOPSIS
00656  * Bool store_asimage( ASImageManager* imageman, ASImage *im, 
00657  *                                         const char *name );
00658  * INPUTS
00659  * imageman        - pointer to valid ASImageManager object.
00660  * im              - pointer to the image to be stored.
00661  * name            - unique name of the image.
00662  * DESCRIPTION
00663  * Adds specifyed image to the ASImageManager's list of referenced images.
00664  * Stored ASImage could be deallocated only by release_asimage(), or when
00665  * ASImageManager object itself is destroyed.
00666  *********/
00667 /****f* libAfterImage/asimage/relocate_asimage()
00668  * NAME
00669  * relocate_asimage()  relocate ASImage into a different image manager.
00670  * SYNOPSIS
00671  * void  relocate_asimage( ASImageManager* to_imageman, ASImage *im );
00672  * INPUTS
00673  * to_imageman        - pointer to valid ASImageManager object.
00674  * im              - pointer to the image to be stored.
00675  * DESCRIPTION
00676  * Moves image from one ASImageManager's list of referenced images into 
00677  * another ASImageManager. Reference count will be kept the same.
00678  *********/
00679 Bool     store_asimage( ASImageManager* imageman, ASImage *im, const char *name );
00680 void     relocate_asimage( ASImageManager* to_imageman, ASImage *im );
00681 
00682 /****f* libAfterImage/asimage/fetch_asimage()
00683  * NAME
00684  * fetch_asimage()
00685  * NAME
00686  * query_asimage() 
00687  * SYNOPSIS
00688  * ASImage *fetch_asimage( ASImageManager* imageman, const char *name );
00689  * ASImage *query_asimage( ASImageManager* imageman, const char *name );
00690  * INPUTS
00691  * imageman        - pointer to valid ASImageManager object.
00692  * name            - unique name of the image.
00693  * DESCRIPTION
00694  * Looks for image with the name in ASImageManager's list and if found,
00695  * returns pointer to it. Note that query_asimage() does not increment 
00696  * reference count, while fetch_asimage() does. Therefore if fetch_asimage()
00697  * is used - release_asimage() should be called , when image is no longer 
00698  * in use.
00699  *********/
00700 ASImage *fetch_asimage( ASImageManager* imageman, const char *name );
00701 ASImage *query_asimage( ASImageManager* imageman, const char *name );
00702 
00703 /****f* libAfterImage/asimage/dup_asimage()
00704  * NAME
00705  * dup_asimage() increment reference count of stored ASImage.
00706  * SYNOPSIS
00707  * ASImage *dup_asimage( ASImage* im );
00708  * INPUTS
00709  * im              - pointer to already referenced image.
00710  *********/
00711 ASImage *dup_asimage  ( ASImage* im );         /* increment ref countif applicable */
00712 
00713 /****f* libAfterImage/asimage/release_asimage()
00714  * NAME
00715  * release_asimage() decrement reference count for given ASImage. 
00716  * NAME
00717  * release_asimage_by_name() decrement reference count for ASImage 
00718  * identifyed by its name. 
00719  * SYNOPSIS
00720  * int  release_asimage( ASImage *im );
00721  * int release_asimage_by_name( ASImageManager *imman, char *name );
00722  * INPUTS
00723  * im              - pointer to already referenced image.
00724  * imageman        - pointer to valid ASImageManager object.
00725  * name            - unique name of the image.
00726  * DESCRIPTION
00727  * Decrements reference count on the ASImage object and destroys it if
00728  * reference count is below zero.
00729  *********/
00730 int      release_asimage( ASImage *im );
00731 int              release_asimage_by_name( ASImageManager *imman, char *name );
00732 
00733 /****f* libAfterImage/asimage/forget_asimage()
00734  * NAME
00735  * forget_asimage() remove ASImage from ASImageManager's hash by pointer.
00736  * NAME
00737  * forget_asimage_name() remove ASImage from ASImageManager's hash by its 
00738  * name.
00739  * SYNOPSIS
00740  * void  forget_asimage( ASImage *im );
00741  * void  forget_asimage_name( ASImageManager *imman, const char *name );
00742  * INPUTS
00743  * im       pointer to already referenced image.
00744  * imageman pointer to valid ASImageManager object.
00745  * name     unique name of the image.
00746  *********/
00747 void     forget_asimage( ASImage *im );
00748 void     forget_asimage_name( ASImageManager *imman, const char *name );
00749 
00750 /****f* libAfterImage/safe_asimage_destroy()
00751  * NAME
00752  * safe_asimage_destroy() either release or destroy asimage, checking
00753  * if it is attached to ASImageManager.
00754  * SYNOPSIS
00755  * int           safe_asimage_destroy( ASImage *im );
00756  * INPUTS
00757  * im  pointer to and ASImage structure.
00758  *********/
00759 int              safe_asimage_destroy( ASImage *im );
00760 
00761 /****f* libAfterImage/print_asimage_manager()
00762  * NAME
00763  * print_asimage_manager() prints list of images referenced in given 
00764  * ASImageManager structure.
00765  *********/
00766 void     print_asimage_manager(ASImageManager *imageman);
00767 
00768 /****f* libAfterImage/asimage/destroy_asgradient()
00769  * NAME
00770  * destroy_asgradient() - destroy ASGradient structure, deallocating all
00771  *                                                associated memory
00772  *********/
00773 void  destroy_asgradient( ASGradient **pgrad );
00774 
00775 /****f* libAfterImage/asimage/flip_gradient()
00776  * NAME 
00777  * flip_gradient()    - rotates gradient in 90 degree increments.
00778  * SYNOPSIS
00779  * ASGradient *flip_gradient( ASGradient *orig, int flip );
00780  * INPUTS
00781  * orig       - pointer to original ASGradient structure to be rotated.
00782  * flip       - value defining desired rotation.
00783  * RETURN VALUE
00784  * Same as original gradient if flip is 0. New gradient structure in any
00785  * other case.
00786  * DESCRIPTION
00787  * Rotates ( flips ) gradient data in 90 degree increments. When needed
00788  * order of points is reversed.
00789  *********/
00790 ASGradient *flip_gradient( ASGradient *orig, int flip );
00791 /****f* libAfterImage/asimage/init_image_layers()
00792  * NAME 
00793  * init_image_layers()    - initialize set of ASImageLayer structures.
00794  * SYNOPSIS
00795  * void init_image_layers( register ASImageLayer *l, int count );
00796  * INPUTS
00797  * l              - pointer to valid ASImageLayer structure.
00798  * count          - number of elements to initialize.
00799  * DESCRIPTION
00800  * Initializes array on ASImageLayer structures to sensible defaults.
00801  * Basically - all zeros and merge_scanlines == alphablend_scanlines.
00802  *********/
00803 void init_image_layers( register ASImageLayer *l, int count );
00804 /****f* libAfterImage/asimage/create_image_layers()
00805  * NAME 
00806  * create_image_layers()  - allocate and initialize set of ASImageLayer's.
00807  * SYNOPSIS
00808  * ASImageLayer *create_image_layers( int count );
00809  * INPUTS
00810  * count       - number of ASImageLayer structures in allocated array.
00811  * RETURN VALUE
00812  * Pointer to newly allocated and initialized array of ASImageLayer
00813  * structures on Success. NULL in case of any kind of error - that
00814  * should never happen.
00815  * DESCRIPTION
00816  * Performs memory allocation for the new array of ASImageLayer
00817  * structures, as well as initialization of allocated structure to
00818  * sensible defaults - merge_func will be set to alphablend_scanlines.
00819  *********/
00820 ASImageLayer *create_image_layers( int count );
00821 /****f* libAfterImage/asimage/destroy_image_layers()
00822  * NAME 
00823  * destroy_image_layers() - destroy set of ASImageLayer structures.
00824  * SYNOPSIS
00825  * void destroy_image_layers( register ASImageLayer *l,
00826  *                            int count,
00827  *                            Bool reusable );
00828  * INPUTS
00829  * l                    - pointer to pointer to valid array of ASImageLayer
00830  *                structures.
00831  * count        - number of structures in array.
00832  * reusable     - if True - then array itself will not be deallocates -
00833  *                    which is usable when it was allocated on stack.
00834  * DESCRIPTION
00835  * frees all the memory allocated for specified array of ASImageLayer s.
00836  * If there was ASImage and/or ASImageBevel attached to it - it will be
00837  * deallocated as well.
00838  *********/
00839 void destroy_image_layers( register ASImageLayer *l, int count, Bool reusable );
00840 
00841 /****f* libAfterImage/asimage/asimage_add_line()
00842  * NAME
00843  * asimage_add_line()
00844  * SYNOPSIS
00845  * size_t asimage_add_line ( ASImage * im, ColorPart color,
00846  *                           CARD32 * data, unsigned int y);
00847  * INPUTS
00848  * im      - pointer to valid ASImage structure
00849  * color   - color channel's number
00850  * data    - raw channel data of 32 bits per pixel - only lowest 8 bits
00851  *           gets encoded.
00852  * y       - image row starting with 0
00853  * RETURN VALUE
00854  * asimage_add_line() return size of the encoded channel scanline in
00855  * bytes. On failure it will return 0.
00856  * DESCRIPTION
00857  * Encodes raw data of the single channel into ASImage channel scanline.
00858  * based on compression level selected for this ASImage all or part of
00859  * the scanline will be RLE encoded.
00860  *********/
00861 /****f* libAfterImage/asimage/asimage_add_line_mono()
00862  * NAME
00863  * asimage_add_line_mono()
00864  * SYNOPSIS
00865  * size_t asimage_add_line_mono ( ASImage * im, ColorPart color,
00866  *                                CARD8 value, unsigned int y);
00867  * INPUTS
00868  * im                           - pointer to valid ASImage structure
00869  * color                        - color channel's number
00870  * value                        - value for the channel
00871  * y                            - image row starting with 0
00872  * RETURN VALUE
00873  * asimage_add_line_mono() return size of the encoded channel scanline
00874  * in bytes. On failure it will return 0.
00875  * DESCRIPTION
00876  * encodes ASImage channel scanline to have same color components
00877  * value in every pixel. Useful for vertical gradients for example.
00878  *********/
00879 /****f* libAfterImage/asimage/get_asimage_chanmask()
00880  * NAME
00881  * get_asimage_chanmask()
00882  * SYNOPSIS
00883  * ASFlagType get_asimage_chanmask( ASImage *im);
00884  * INPUTS
00885  * im         - valid ASImage object.
00886  * DESCRIPTION
00887  * goes throu all the scanlines of the ASImage and toggles bits 
00888  * representing those components that have at least some data.
00889  *********/
00890 /****f* libAfterImage/asimage/move_asimage_channel()
00891  * NAME
00892  * move_asimage_channel()
00893  * SYNOPSIS
00894  * void move_asimage_channel( ASImage *dst, int channel_dst,
00895  *                            ASImage *src, int channel_src );
00896  * INPUTS
00897  * dst         - ASImage which will have its channel substituted;
00898  * channel_dst - what channel to move data to;
00899  * src         - ASImage which will donate its channel to dst;
00900  * channel_src - what source image channel to move data from.
00901  * DESCRIPTION
00902  * MOves channel data from one ASImage to another, while discarding
00903  * what was already in destination's channel.
00904  * NOTES
00905  * Source image (donor) will loose its channel data, as it will be
00906  * moved to destination ASImage. Also there is a condition that both
00907  * images must be of the same width - otherwise function returns
00908  * without doing anything. If height is different - the minimum of
00909  * two will be used.
00910  *********/
00911 /****f* libAfterImage/asimage/copy_asimage_channel()
00912  * NAME
00913  * copy_asimage_channel()
00914  * SYNOPSIS
00915  * void copy_asimage_channel( ASImage *dst, int channel_dst,
00916  *                            ASImage *src, int channel_src );
00917  * INPUTS
00918  * dst         - ASImage which will have its channel substituted;
00919  * channel_dst - what channel to copy data to;
00920  * src         - ASImage which will donate its channel to dst;
00921  * channel_src - what source image channel to copy data from.
00922  * DESCRIPTION
00923  * Same as move_asimage_channel() but makes copy of channel's data
00924  * instead of simply moving it from one image to another.
00925  *********/
00926 /****f* libAfterImage/asimage/copy_asimage_lines()
00927  * NAME
00928  * copy_asimage_lines()
00929  * SYNOPSIS
00930  * void copy_asimage_lines( ASImage *dst, unsigned int offset_dst,
00931  *                          ASImage *src, unsigned int offset_src,
00932  *                          unsigned int nlines, ASFlagType filter );
00933  * INPUTS
00934  * dst         - ASImage which will have its channel substituted;
00935  * offset_dst  - scanline in destination image to copy to;
00936  * src         - ASImage which will donate its channel to dst;
00937  * offset_src  - scanline in source image to copy data from;
00938  * nlines      - number of scanlines to be copied;
00939  * filter      - specifies what channels should be copied.
00940  * DESCRIPTION
00941  * Makes copy of scanline data for continuos set of scanlines, affecting
00942  * only those channels marked in filter.
00943  * NOTE
00944  * Images must be of the same width.
00945  *********/
00946 size_t asimage_add_line (ASImage * im, ColorPart color, CARD32 * data, unsigned int y);
00947 size_t asimage_add_line_mono (ASImage * im, ColorPart color, CARD8 value, unsigned int y);
00948 size_t asimage_add_line_bgra (ASImage * im, register CARD32 * data, unsigned int y);
00949 
00950 ASFlagType get_asimage_chanmask( ASImage *im);
00951 int check_asimage_alpha (ASVisual *asv, ASImage *im );
00952 int asimage_decode_line (ASImage * im, ColorPart color, CARD32 * to_buf, unsigned int y, unsigned int skip, unsigned int out_width);
00953 void move_asimage_channel( ASImage *dst, int channel_dst, ASImage *src, int channel_src );
00954 void copy_asimage_channel( ASImage *dst, int channel_dst, ASImage *src, int channel_src );
00955 void copy_asimage_lines( ASImage *dst, unsigned int offset_dst,
00956                          ASImage *src, unsigned int offset_src,
00957                                                  unsigned int nlines, ASFlagType filter );
00958 /****d* libAfterImage/asimage/verbosity
00959  * FUNCTION
00960  * This are flags that define what should be printed by
00961  * asimage_print_line():
00962  *      VRB_LINE_SUMMARY        - print only summary for each scanline
00963  *      VRB_LINE_CONTENT        - print summary and data for each scanline
00964  *      VRB_CTRL_EXPLAIN        - print summary, data and control codes for each
00965  *                                                scanline
00966  * SOURCE
00967  */
00968 #define VRB_LINE_SUMMARY        (0x01<<0)
00969 #define VRB_LINE_CONTENT        (0x01<<1)
00970 #define VRB_CTRL_EXPLAIN        (0x01<<2)
00971 #define VRB_EVERYTHING          (VRB_LINE_SUMMARY|VRB_CTRL_EXPLAIN| \
00972                                                          VRB_LINE_CONTENT)
00973 /*********/
00974 /****f* libAfterImage/asimage/asimage_print_line()
00975  * NAME
00976  * asimage_print_line()
00977  * SYNOPSIS
00978  *      unsigned int asimage_print_line ( ASImage * im, ColorPart color,
00979  *                                                                        unsigned int y,
00980  *                                                                        unsigned long verbosity);
00981  * INPUTS
00982  * im                           - pointer to valid ASImage structure
00983  * color                        - color channel's number
00984  * y                            - image row starting with 0
00985  * verbosity            - verbosity level - any combination of flags is
00986  *                  allowed
00987  * RETURN VALUE
00988  * amount of memory used by this particular channel of specified
00989  * scanline.
00990  * DESCRIPTION
00991  * asimage_print_line() prints data stored in specified image scanline
00992  * channel. That may include simple summary of how much memory is used,
00993  * actual visible data, and/or RLE control codes. That helps to see
00994  * how effectively data is encoded.
00995  *
00996  * Useful mostly for debugging purposes.
00997  *********/
00998 unsigned int asimage_print_line (ASImage * im, ColorPart color,
00999                                  unsigned int y, unsigned long verbosity);
01000 void print_asimage( ASImage *im, int flags, char * func, int line );
01001 
01002 void print_asimage_func (ASHashableValue value);
01003 #define print_asimage_ptr (ptr)  print_asimage_func(AS_HASHABLE(ptr))
01004 void print_asimage_registry();                 /* TRACK_ASIMAGES must be defined for this to work */
01005 void purge_asimage_registry();
01006 
01007 
01008 /* the following 5 macros will in fact unfold into huge but fast piece of code : */
01009 /* we make poor compiler work overtime unfolding all this macroses but I bet it  */
01010 /* is still better then C++ templates :)                                                                             */
01011 
01012 #define ENCODE_SCANLINE(im,src,y) \
01013 do{     asimage_add_line((im), IC_RED,   (src).red,   (y)); \
01014         asimage_add_line((im), IC_GREEN, (src).green, (y)); \
01015         asimage_add_line((im), IC_BLUE,  (src).blue,  (y)); \
01016         if( get_flags((src).flags,SCL_DO_ALPHA))asimage_add_line((im), IC_ALPHA, (src).alpha, (y)); \
01017   }while(0)
01018 
01019 #define SCANLINE_FUNC(f,src,dst,scales,len) \
01020 do{     if( (src).offset_x > 0 || (dst).offset_x > 0 ) \
01021                 LOCAL_DEBUG_OUT( "(src).offset_x = %d. (dst).offset_x = %d", (src).offset_x, (dst).offset_x ); \
01022         f((src).red+(src).offset_x,  (dst).red+(dst).offset_x,  (scales),(len));                \
01023         f((src).green+(src).offset_x,(dst).green+(dst).offset_x,(scales),(len));                \
01024         f((src).blue+(src).offset_x, (dst).blue+(dst).offset_x, (scales),(len));        \
01025         if(get_flags((src).flags,SCL_DO_ALPHA)) f((src).alpha+(src).offset_x,(dst).alpha+(dst).offset_x,(scales),(len)); \
01026   }while(0)
01027 
01028 #define SCANLINE_FUNC_FILTERED(f,src,dst,scales,len) \
01029 do{     if( (src).offset_x > 0 || (dst).offset_x > 0 ) \
01030                 LOCAL_DEBUG_OUT( "(src).offset_x = %d. (dst).offset_x = %d", (src).offset_x, (dst).offset_x ); \
01031     if(get_flags((src).flags,SCL_DO_RED)) f((src).red+(src).offset_x,  (dst).red+(dst).offset_x,  (scales),(len));        \
01032     if(get_flags((src).flags,SCL_DO_GREEN)) f((src).green+(src).offset_x,(dst).green+(dst).offset_x,(scales),(len));        \
01033     if(get_flags((src).flags,SCL_DO_BLUE)) f((src).blue+(src).offset_x, (dst).blue+(dst).offset_x, (scales),(len));    \
01034         if(get_flags((src).flags,SCL_DO_ALPHA)) f((src).alpha+(src).offset_x,(dst).alpha+(dst).offset_x,(scales),(len)); \
01035   }while(0)
01036 
01037 #define CHOOSE_SCANLINE_FUNC(r,src,dst,scales,len) \
01038  switch(r)                                                                                                      \
01039  {  case 0:     SCANLINE_FUNC(shrink_component11,(src),(dst),(scales),(len));break;     \
01040         case 1: SCANLINE_FUNC(shrink_component, (src),(dst),(scales),(len));    break;  \
01041         case 2: SCANLINE_FUNC(enlarge_component_dumb,(src),(dst),(scales),(len));break ;\
01042         case 3: SCANLINE_FUNC(enlarge_component12,(src),(dst),(scales),(len));break ;   \
01043         case 4: SCANLINE_FUNC(enlarge_component23,(src),(dst),(scales),(len));break;    \
01044         default:SCANLINE_FUNC(enlarge_component,  (src),(dst),(scales),(len));          \
01045  }
01046 
01047 #define SCANLINE_MOD(f,src,p,len) \
01048 do{     f((src).red+(src).offset_x,(p),(len));          \
01049         f((src).green+(src).offset_x,(p),(len));                \
01050         f((src).blue+(src).offset_x,(p),(len));         \
01051         if(get_flags((src).flags,SCL_DO_ALPHA)) f((src).alpha+(src).offset_x,(p),(len));\
01052   }while(0)
01053 
01054 #define SCANLINE_MOD_FILTERED(f,src,p,len) \
01055 do{ if(get_flags((src).flags,SCL_DO_RED)) f((src).red+(src).offset_x,(p),(len));      \
01056     if(get_flags((src).flags,SCL_DO_GREEN)) f((src).green+(src).offset_x,(p),(len));        \
01057     if(get_flags((src).flags,SCL_DO_BLUE)) f((src).blue+(src).offset_x,(p),(len));     \
01058         if(get_flags((src).flags,SCL_DO_ALPHA)) f((src).alpha+(src).offset_x,(p),(len));\
01059   }while(0)
01060 
01061 #define SCANLINE_COMBINE_slow(f,c1,c2,c3,c4,o1,o2,p,len)                                                   \
01062 do{     f((c1).red,(c2).red,(c3).red,(c4).red,(o1).red,(o2).red,(p),(len));             \
01063         f((c1).green,(c2).green,(c3).green,(c4).green,(o1).green,(o2).green,(p),(len)); \
01064         f((c1).blue,(c2).blue,(c3).blue,(c4).blue,(o1).blue,(o2).blue,(p),(len));               \
01065         if(get_flags((c1).flags,SCL_DO_ALPHA)) f((c1).alpha,(c2).alpha,(c3).alpha,(c4).alpha,(o1).alpha,(o2).alpha,(p),(len));  \
01066   }while(0)
01067 
01068 #define SCANLINE_COMBINE(f,c1,c2,c3,c4,o1,o2,p,len)                                                \
01069 do{     f((c1).red,(c2).red,(c3).red,(c4).red,(o1).red,(o2).red,(p),(len+(len&0x01))*3);                \
01070         if(get_flags((c1).flags,SCL_DO_ALPHA)) f((c1).alpha,(c2).alpha,(c3).alpha,(c4).alpha,(o1).alpha,(o2).alpha,(p),(len));  \
01071   }while(0)
01072 
01073 
01074 /* note that we shift values by 8 to keep quanitzation error in   */
01075 /* lower 1 byte for subsequent dithering        :                                         */
01076 #define QUANT_ERR_BITS          8
01077 #define QUANT_ERR_MASK          0x000000FF
01078 
01079 void copy_component( register CARD32 *src, register CARD32 *dst, int *unused, int len );
01080 
01081 #ifdef X_DISPLAY_MISSING
01082 typedef struct XRectangle
01083 {
01084         short x, y;
01085         unsigned short width, height ;
01086 }XRectangle ;
01087 #endif
01088 
01089 /****f* libAfterImage/asimage/get_asimage_channel_rects()
01090  * NAME
01091  * get_asimage_channel_rects() - translate image into a 
01092  * list of rectangles.
01093  * SYNOPSIS
01094  * XRectangle* 
01095  *     get_asimage_channel_rects( ASImage *src, int channel, 
01096  *                                unsigned int threshold, 
01097  *                                unsigned int *rects_count_ret ); 
01098  * INPUTS
01099  * src         - ASImage which will donate its channel to dst;
01100  * channel     - what source image channel to copy data from;
01101  * threshold   - threshold to compare channel values against;
01102  * rects_count_ret - returns count of generated rectangles.
01103  * DESCRIPTION
01104  * This function will translate contents of selected channel 
01105  * (usualy alpha) into a list of rectangles, ecompasing regions 
01106  * with values above the threshold. This is usefull to generate shape
01107  * of the window to be used with X Shape extention.
01108  *********/
01109 XRectangle*
01110 get_asimage_channel_rects( ASImage *src, int channel, unsigned int threshold, unsigned int *rects_count_ret );
01111 
01112 void
01113 raw2scanline( register CARD8 *row, struct ASScanline *buf, CARD8 *gamma_table, unsigned int width, Bool grayscale, Bool do_alpha );
01114 
01115 #ifdef __cplusplus
01116 }
01117 #endif
01118 
01119 
01120 #endif

Generated on Tue Jul 5 14:13:26 2011 for ROOT_528-00b_version by  doxygen 1.5.1