export.h

Go to the documentation of this file.
00001 #ifndef EXPORT_H_HEADER_INCLUDED
00002 #define EXPORT_H_HEADER_INCLUDED
00003 
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 /****h* libAfterImage/export.h
00009  * NAME
00010  * export - Image output into different file formats.
00011  * SEE ALSO
00012  * Structures :
00013  *          ASXpmExportParams
00014  *          ASPngExportParams
00015  *          ASJpegExportParams
00016  *          ASGifExportParams
00017  *          ASImageExportParams
00018  *
00019  * Functions :
00020  *              ASImage2file()
00021  *
00022  * Other libAfterImage modules :
00023  *          ascmap.h asfont.h asimage.h asvisual.h blender.h export.h
00024  *          import.h transform.h ximage.h
00025  * AUTHOR
00026  * Sasha Vasko <sasha at aftercode dot net>
00027  ******************/
00028 
00029 /****d* libAfterImage/ExportFlags
00030  * NAME
00031  * EXPORT_GRAYSCALE - save image as grayscale.
00032  * NAME
00033  * EXPORT_ALPHA - save alpha channel if format permits
00034  * NAME
00035  * EXPORT_APPEND - if format allows multiple images - image will be 
00036  * appended
00037  * FUNCTION
00038  * Some common flags that could be used while writing images into
00039  * different file formats.
00040  * SOURCE
00041  */
00042 #define EXPORT_GRAYSCALE                        (0x01<<0)
00043 #define EXPORT_ALPHA                            (0x01<<1)
00044 #define EXPORT_APPEND                           (0x01<<3)  /* adds subimage  */
00045 #define EXPORT_ANIMATION_REPEATS        (0x01<<4)  /* number of loops to repeat GIF animation */
00046 /*****/
00047 
00048 /****s* libAfterImage/ASXpmExportParams
00049  * NAME
00050  * ASXpmExportParams - parameters for export into XPM file.
00051  * SOURCE
00052  */
00053 typedef struct
00054 {
00055         ASImageFileTypes type;
00056         ASFlagType flags ;
00057         int dither ;
00058         int opaque_threshold ;
00059         int max_colors ;
00060 }ASXpmExportParams ;
00061 /*******/
00062 /****s* libAfterImage/ASPngExportParams
00063  * NAME
00064  * ASPngExportParams - parameters for export into PNG file.
00065  * SOURCE
00066  */
00067 typedef struct
00068 {
00069         ASImageFileTypes type;
00070         ASFlagType flags ;
00071         int compression ;
00072 }ASPngExportParams ;
00073 /*******/
00074 /****s* libAfterImage/ASJpegExportParams
00075  * NAME
00076  * ASJpegExportParams - parameters for export into JPEG file.
00077  * SOURCE
00078  */
00079 typedef struct
00080 {
00081         ASImageFileTypes type;
00082         ASFlagType flags ;
00083         int quality ;
00084 }ASJpegExportParams ;
00085 /*******/
00086 /****s* libAfterImage/ASGifExportParams
00087  * NAME
00088  * ASGifExportParams - parameters for export into GIF file.
00089  * SOURCE
00090  */
00091 typedef struct
00092 {
00093         ASImageFileTypes type;
00094         ASFlagType flags ;
00095         int dither ;
00096         int opaque_threshold ;
00097         unsigned short animate_delay ;
00098         unsigned short animate_repeats ;
00099 }ASGifExportParams ;
00100 /*******/
00101 /****s* libAfterImage/ASTiffExportParams
00102  * NAME
00103  * ASTiffExportParams - parameters for export into TIFF file.
00104  * SOURCE
00105  */
00106 typedef struct
00107 {
00108         ASImageFileTypes type;
00109         ASFlagType flags ;
00110         CARD32 rows_per_strip ;
00111 
00112 /* these are suitable compressions : */
00113 #define TIFF_COMPRESSION_NONE           1
00114 #define TIFF_COMPRESSION_OJPEG          6       /* !6.0 JPEG */
00115 #define TIFF_COMPRESSION_JPEG           7
00116 #define TIFF_COMPRESSION_PACKBITS       32773   /* Macintosh RLE */
00117 #define TIFF_COMPRESSION_DEFLATE        32946   /* Deflate compression */
00118         /* you should be able to use other values from tiff.h as well */
00119         CARD32 compression_type ;
00120         int jpeg_quality ;
00121 
00122         int opaque_threshold ;
00123 }ASTiffExportParams ;
00124 /*******/
00125 /****s* libAfterImage/ASImageExportParams
00126  * NAME
00127  * ASImageExportParams - union of structures holding parameters for
00128  *   export into different file formats.
00129  * DESCRIPTION
00130  * Treatment of this union depends on what type of export was requested.
00131  * SEE ALSO
00132  * ASImageFileTypes
00133  * SOURCE
00134  */
00135 typedef union ASImageExportParams
00136 {
00137         ASImageFileTypes   type;
00138         ASXpmExportParams  xpm;
00139         ASPngExportParams  png;
00140         ASJpegExportParams jpeg;
00141         ASGifExportParams  gif;
00142         ASTiffExportParams tiff;
00143 }ASImageExportParams;
00144 /******/
00145 
00146 typedef Bool (*as_image_writer_func)( ASImage *im, const char *path,
00147                                                                           ASImageExportParams *params );
00148 extern as_image_writer_func as_image_file_writers[ASIT_Unknown];
00149 
00150 
00151 /****f* libAfterImage/export/ASImage2file()
00152  * NAME
00153  * ASImage2file()
00154  * SYNOPSIS
00155  * Bool ASImage2file( ASImage *im, const char *dir, const char *file,
00156                                           ASImageFileTypes type, ASImageExportParams *params );
00157  * INPUTS
00158  * im                   - Image to write out.
00159  * dir          - directory name to write file into (optional,
00160  *                could be NULL)
00161  * file         - file name with or without directory name.
00162  * type         - output file format. ( see ASImageFileTypes )
00163  * params       - pointer to ASImageExportParams union's member for the
00164  *                above type, with additional export parameters, such as
00165  *                quality, compression, etc. If NULL then all defaults
00166  *                will be used.
00167  * RETURN VALUE
00168  * True on success. False - failure.
00169  * DESCRIPTION
00170  * ASImage2file will construct filename out of dir and file components
00171  * and then will call specific filter to write out file in requested
00172  * format.
00173  * NOTES
00174  * Some formats support compression, others support lossy compression,
00175  * yet others allows you to limit number of colors and colordepth.
00176  * Each specific filter will try to interpret those parameters in its
00177  * own way.
00178  * EXAMPLE
00179  * asmerge.c: ASMerge.3
00180  *********/
00181 
00182 Bool
00183 ASImage2file( ASImage *im, const char *dir, const char *file,
00184                           ASImageFileTypes type, ASImageExportParams *params );
00185 
00186 
00187 Bool
00188 ASImage2PNGBuff( ASImage *im, CARD8 **buffer, int *size, ASImageExportParams *params );
00189 Bool
00190 ASImage2xpmRawBuff( ASImage *im, CARD8 **buffer, int *size, ASImageExportParams *params );
00191 
00192 
00193 Bool ASImage2xpm ( ASImage *im, const char *path, ASImageExportParams *params );
00194 Bool ASImage2png ( ASImage *im, const char *path, ASImageExportParams *params );
00195 Bool ASImage2jpeg( ASImage *im, const char *path, ASImageExportParams *params );
00196 Bool ASImage2xcf ( ASImage *im, const char *path, ASImageExportParams *params );
00197 Bool ASImage2ppm ( ASImage *im, const char *path, ASImageExportParams *params );
00198 Bool ASImage2bmp ( ASImage *im, const char *path, ASImageExportParams *params );
00199 Bool ASImage2ico ( ASImage *im, const char *path, ASImageExportParams *params );
00200 Bool ASImage2gif ( ASImage *im, const char *path, ASImageExportParams *params );
00201 Bool ASImage2tiff( ASImage *im, const char *path, ASImageExportParams *params );
00202 
00203 #ifdef __cplusplus
00204 }
00205 #endif
00206 
00207 
00208 #endif

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