import.h

Go to the documentation of this file.
00001 #ifndef IMPORT_H_HEADER_INCLUDED
00002 #define IMPORT_H_HEADER_INCLUDED
00003 
00004 #include "asimage.h"
00005 #include "xcf.h"
00006 #include "xpm.h"
00007 
00008 #ifdef __cplusplus
00009 extern "C" {
00010 #endif
00011 
00012 
00013 /****h* libAfterImage/import.h
00014  * NAME
00015  * import - Image file format autodetection, reading and decoding 
00016  * routines.
00017  * SEE ALSO
00018  * Functions :
00019  *              file2ASImage(), get_asimage(), file2pixmap()
00020  *
00021  * Other libAfterImage modules :
00022  *          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
00023  *          import.h transform.h ximage.h
00024  * AUTHOR
00025  * Sasha Vasko <sasha at aftercode dot net>
00026  ******************/
00027 
00028 /****d* libAfterImage/gamma
00029  * NAME
00030  * SCREEN_GAMMA - Defines default value for screen gamma correction.
00031  * SOURCE
00032  */
00033 #define SCREEN_GAMMA 2.2
00034 #define DEFAULT_PNG_IMAGE_GAMMA     0.45455
00035 /*************/
00036 /****s* libAfterImage/ASImageFileTypes
00037  * NAME
00038  * ASImageFileTypes - List of known image file formats.
00039  * SOURCE
00040  */
00041 typedef enum
00042 {
00043         ASIT_Xpm = 0,
00044         ASIT_ZCompressedXpm,
00045         ASIT_GZCompressedXpm,
00046         ASIT_Png,
00047         ASIT_Jpeg,
00048         ASIT_Xcf,
00049         ASIT_Ppm,
00050         ASIT_Pnm,
00051         ASIT_Bmp,
00052         ASIT_Ico,
00053         ASIT_Cur,
00054         ASIT_Gif,
00055         ASIT_Tiff,
00056         ASIT_XMLScript,
00057         ASIT_SVG,
00058         /* reserved for future implementation : */
00059         ASIT_Xbm,
00060         ASIT_Targa,
00061         ASIT_Supported = ASIT_Targa,
00062         ASIT_Pcx,
00063         ASIT_HTML,
00064         ASIT_XML,
00065         ASIT_Unknown
00066 }ASImageFileTypes;
00067 /*************/
00068 
00069 /****s* libAfterImage/ASImageListEntry
00070  * NAME
00071  * ASImageListEntry - entry in linked list of images loaded from single 
00072  * directory.
00073  * SOURCE
00074  */
00075 typedef struct ASImageListEntryBuffer
00076 {
00077 #define ASILEB_Dirty            (0x01<<0)                  
00078 #define ASILEB_Binary           (0x01<<1)                  
00079 
00080         ASFlagType flags ; 
00081 
00082         size_t size ; 
00083         char  *data ; 
00084         
00085 }ASImageListEntryBuffer;
00086 
00087 typedef struct ASImageListEntry
00088 {
00089 #define MAGIC_ASIMAGE_LIST_ENTRY            0xA3A311E4
00090 #define IS_ASIMAGE_LIST_ENTRY(e)  (((e)!=NULL)&&((e)->magic==MAGIC_ASIMAGE_LIST_ENTRY)&&((e)->ref_count>0)) 
00091 
00092         unsigned long magic ; 
00093         struct ASImageListEntry *prev, *next ;
00094         char   *name ;
00095         char   *fullfilename ;
00096 
00097         ASImageFileTypes        type;
00098         ASImage                    *preview;
00099 
00100 #ifndef _WIN32
00101         mode_t d_mode;
00102 #endif
00103     time_t d_mtime;
00104         off_t  d_size;          /* total size, in bytes */
00105 
00106         ASImageListEntryBuffer *buffer ; 
00107 
00108         int ref_count;
00109 }ASImageListEntry;
00110 /*************/
00111 
00112 #define AS_IMPORT_ORIGINAL              0
00113 #define AS_IMPORT_RESIZE_H              (0x01<<1)
00114 #define AS_IMPORT_RESIZE_V              (0x01<<2)
00115 #define AS_IMPORT_RESIZED               (AS_IMPORT_RESIZE_V|AS_IMPORT_RESIZE_H)
00116 #define AS_IMPORT_SCALED_H              (0x01<<3)      /* if unset - then tile */
00117 #define AS_IMPORT_SCALED_V              (0x01<<4)      /* if unset - then tile */
00118 #define AS_IMPORT_SCALED_BOTH   (AS_IMPORT_SCALED_H|AS_IMPORT_SCALED_V)
00119 #define AS_IMPORT_FAST                  (0x01<<5)      /* can sacrifice quality for speed */
00120 
00121 
00122 typedef struct ASImageImportParams
00123 {
00124         ASFlagType              flags ;                         /* see above */
00125         int                     width, height ;
00126         ASFlagType              filter ;                                           /* what channels to load */
00127         double                  gamma ;
00128         CARD8              *gamma_table ;
00129         int                     subimage ;
00130         ASAltImFormats  format ;
00131         unsigned int    compression ;
00132         char              **search_path ;                 /* NULL terminated list  */
00133         
00134         int                     return_animation_delay ;
00135         int                     return_animation_repeats ;
00136 }ASImageImportParams;
00137 
00138 typedef ASImage* (*as_image_loader_func)( const char * path, ASImageImportParams *params );
00139 extern as_image_loader_func as_image_file_loaders[ASIT_Unknown];
00140 
00141 ASImage *xpm2ASImage ( const char * path, ASImageImportParams *params );
00142 ASImage *xpm_data2ASImage( const char **data, ASImageImportParams *params );
00143 ASImage *xpmRawBuff2ASImage( const char *data, ASImageImportParams *params );
00144 ASImage *png2ASImage ( const char * path, ASImageImportParams *params );
00145 ASImage *jpeg2ASImage( const char * path, ASImageImportParams *params );
00146 ASImage *xcf2ASImage ( const char * path, ASImageImportParams *params );
00147 ASImage *ppm2ASImage ( const char * path, ASImageImportParams *params );
00148 ASImage *bmp2ASImage ( const char * path, ASImageImportParams *params );
00149 ASImage *ico2ASImage ( const char * path, ASImageImportParams *params );
00150 ASImage *gif2ASImage ( const char * path, ASImageImportParams *params );
00151 ASImage *tiff2ASImage( const char * path, ASImageImportParams *params );
00152 ASImage *xml2ASImage ( const char * path, ASImageImportParams *params );
00153 ASImage *tga2ASImage ( const char * path, ASImageImportParams *params );
00154 ASImage *svg2ASImage ( const char * path, ASImageImportParams *params );
00155 ASImage *convert_argb2ASImage( ASVisual *asv, int width, int height, ARGB32 *argb, CARD8 *gamma_table );
00156 ASImage *argb2ASImage( const char *path, ASImageImportParams *params );
00157 
00158 
00159 /****f* libAfterImage/import/file2ASImage()
00160  * NAME
00161  * file2ASImage() - load ASImage from file.
00162  * SYNOPSIS
00163  * ASImage *file2ASImage( const char *file, ASFlagType what,
00164  *                        double gamma,
00165  *                        unsigned int compression, ... );
00166  * INPUTS
00167  * file         - file name with or without directory name
00168  * what         - reserved for future use
00169  * gamma        - gamma value to be used to correct image
00170  * compression  - compression level of the resulting ASImage
00171  * ...          - NULL terminated list of strings, representing
00172  *                arbitrary number of directories to be searched each.
00173  * RETURN VALUE
00174  * Pointer to ASImage structure holding image data on success.
00175  * NULL on failure
00176  * DESCRIPTION
00177  * file2ASImage will attempt to interpret filename in the following way:
00178  * 1)It will try to find file using unmodified filename in all the
00179  * provided search paths.
00180  * 2)It will attempt to append .gz and then .Z to the filename and
00181  * find such file in all the provided search paths.
00182  * 3)If filename ends with extension consisting of digits only - it will
00183  * attempt to find file with this extension stripped off. On success
00184  * this extension will be used to load subimage from the file with that
00185  * number. Subimages are supported only for XCF, GIF, BMP, ICO and CUR
00186  * files.
00187  * After the file is found file2ASImage() attempts to detect file format,
00188  * and if it is known it will load it into new ASImage structure.
00189  * EXAMPLE
00190  * asview.c: ASView.2
00191  *********/
00192 /****f* libAfterImage/import/get_asimage()
00193  * NAME
00194  * get_asimage() - increment reference counter if file is already loaded,
00195  * or load image from file.
00196  * SYNOPSIS
00197  * ASImage *get_asimage( ASImageManager* imageman, const char *file,
00198  *                       ASFlagType what, unsigned int compression );
00199  * INPUTS
00200  * imageman     - pointer to valid ASVisual structure.
00201  * file         - root window ID for the destination screen.
00202  * what         - full image file's name with path.
00203  * compression  -
00204  * RETURN VALUE
00205  * Pointer to ASImage structure holding image data on success.
00206  * NULL on failure
00207  * DESCRIPTION
00208  * get_asimage will attempt check with the ASImageManager's list of load
00209  * images, and if image with requested filename already exists - it will
00210  * increment its reference count and return its pointer.
00211  * Otherwise it will call file2ASImage() to load image from file. It will
00212  * use PATH and gamma values from the ASImageManager to pass to
00213  * file2ASImage(). If image is successfully loaded - it will be added to
00214  * the ASImageManager's list and its pointer will be returned.
00215  * SEE ALSO
00216  * file2ASImage()
00217  *********/
00218 ASImage *file2ASImage( const char *file, ASFlagType what, double gamma, unsigned int compression, ... );
00219 ASImage *file2ASImage_extra( const char *file, ASImageImportParams *params );
00220 ASImage *get_asimage( ASImageManager* imageman, const char *file, ASFlagType what, unsigned int compression );
00221 ASImage *get_asimage_extra( ASImageManager* imageman, const char *file, ASImageImportParams *params );
00222 ASImageFileTypes get_asimage_file_type( ASImageManager* imageman, const char *file );
00223 
00224 #define AS_THUMBNAIL_PROPORTIONAL               (0x01<<0)
00225 #define AS_THUMBNAIL_DONT_ENLARGE               (0x01<<1)
00226 #define AS_THUMBNAIL_DONT_REDUCE                (0x01<<2)
00227 ASImage *get_thumbnail_asimage( ASImageManager* imageman, const char *file, int thumb_width, int thumb_height, ASFlagType flags /* see above */);
00228 
00229 ASImageFileTypes check_asimage_file_type( const char *realfilename );
00230 
00231 
00232 Bool reload_asimage_manager( ASImageManager *imman );
00233 
00234 #define NO_PREVIEW                      0
00235 #define LOAD_PREVIEW            AS_IMPORT_RESIZED
00236 #define SCALE_PREVIEW_H         AS_IMPORT_SCALED_H
00237 #define SCALE_PREVIEW_V         AS_IMPORT_SCALED_V
00238 
00239 ASImageListEntry *get_asimage_list( struct ASVisual *asv, const char *dir,
00240                                         ASFlagType preview_type, double gamma,
00241                                                                         unsigned int preview_width, unsigned int preview_height,
00242                                                                         unsigned int preview_compression,
00243                                                                         unsigned int *count_ret,
00244                                                                         int (*select) (const char *) );
00245 
00246 ASImageListEntry *ref_asimage_list_entry( ASImageListEntry *entry );
00247 ASImageListEntry *unref_asimage_list_entry( ASImageListEntry *entry );
00248 ASImageListEntry *create_asimage_list_entry();
00249 void destroy_asimage_list_entry_buffer( ASImageListEntryBuffer **pbuffer );
00250 void destroy_asimage_list( ASImageListEntry **plist );
00251 char *format_asimage_list_entry_details( ASImageListEntry *entry, Bool vertical );
00252 Bool load_asimage_list_entry_data( ASImageListEntry *entry, size_t max_bytes );
00253 
00254 
00255 /****f* libAfterImage/import/file2pixmap()
00256  * NAME
00257  * file2pixmap() - convinience function to load file into X Pixmap.
00258  * SYNOPSIS
00259  * Pixmap file2pixmap( struct ASVisual *asv, Window root,
00260  *                     const char *realfilename,
00261  *                     Pixmap *mask_out);
00262  * INPUTS
00263  * asv          - pointer to valid ASVisual structure.
00264  * root         - root window ID for the destination screen.
00265  * realfilename - full image file's name with path.
00266  * RETURN VALUE
00267  * Pixmap ID of the X Pixmap filled with loaded image. If mask_out is
00268  * not NULL it will point to image mask Pixmap ID if there is an alpha
00269  * channel in image, None otherwise.
00270  * On failure None will be returned.
00271  * DESCRIPTION
00272  * file2pixmap() will attempt to open specified file and autodetect its
00273  * format. If format is known it will load it into ASImage first, and
00274  * then convert it into X Pixmap. In case image has alpha channel -
00275  * mask Pixmap will be produced if mask_out is not NULL.
00276  *********/
00277 Pixmap file2pixmap(struct ASVisual *asv, Window root, const char *realfilename, Pixmap *mask_out);
00278 
00279 /**** VO ******/
00280 ASImage *PNGBuff2ASimage( CARD8 *buffer, ASImageImportParams *params );
00281 
00282 #ifdef __cplusplus
00283 }
00284 #endif
00285 
00286 #endif
00287 

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