Leptonica 1.68
C Image Processing Library

imageio.h

Go to the documentation of this file.
00001 /*====================================================================*
00002  -  Copyright (C) 2001 Leptonica.  All rights reserved.
00003  -  This software is distributed in the hope that it will be
00004  -  useful, but with NO WARRANTY OF ANY KIND.
00005  -  No author or distributor accepts responsibility to anyone for the
00006  -  consequences of using this software, or for whether it serves any
00007  -  particular purpose or works at all, unless he or she says so in
00008  -  writing.  Everyone is granted permission to copy, modify and
00009  -  redistribute this source code, for commercial or non-commercial
00010  -  purposes, with the following restrictions: (1) the origin of this
00011  -  source code must not be misrepresented; (2) modified versions must
00012  -  be plainly marked as such; and (3) this notice may not be removed
00013  -  or altered from any source or modified source distribution.
00014  *====================================================================*/
00015 
00016 #ifndef  LEPTONICA_IMAGEIO_H
00017 #define  LEPTONICA_IMAGEIO_H
00018 
00019 /* ------------------ Image file format types -------------- */
00020 /*  
00021  *  The IFF_DEFAULT flag is used to write the file out in the
00022  *  same (input) file format that the pix was read from.  If the pix
00023  *  was not read from file, the input format field will be
00024  *  IFF_UNKNOWN and the output file format will be chosen to
00025  *  be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
00026  *  and IFF_PNG for everything else.   IFF_JP2 is for jpeg2000, which
00027  *  is not supported in leptonica.
00028  *
00029  *  In the future, new format types that have defined extensions
00030  *  will be added before IFF_DEFAULT, and will be kept in sync with
00031  *  the file format extensions in writefile.c.  The positions of
00032  *  file formats before IFF_DEFAULT will remain invariant.
00033  */
00034 enum {
00035     IFF_UNKNOWN        = 0,
00036     IFF_BMP            = 1,
00037     IFF_JFIF_JPEG      = 2,
00038     IFF_PNG            = 3,
00039     IFF_TIFF           = 4,
00040     IFF_TIFF_PACKBITS  = 5,
00041     IFF_TIFF_RLE       = 6,
00042     IFF_TIFF_G3        = 7,
00043     IFF_TIFF_G4        = 8,
00044     IFF_TIFF_LZW       = 9,
00045     IFF_TIFF_ZIP       = 10,
00046     IFF_PNM            = 11,
00047     IFF_PS             = 12,
00048     IFF_GIF            = 13,
00049     IFF_JP2            = 14,
00050     IFF_WEBP           = 15,
00051     IFF_LPDF           = 16,
00052     IFF_DEFAULT        = 17,
00053     IFF_SPIX           = 18
00054 };
00055 
00056 
00057 /* ---------------------- Format header ids --------------------- */
00058 enum {
00059     BMP_ID             = 0x4d42,
00060     TIFF_BIGEND_ID     = 0x4d4d,     /* MM - for 'motorola' */
00061     TIFF_LITTLEEND_ID  = 0x4949      /* II - for 'intel'    */
00062 };
00063 
00064 
00065 /* ------------------ Gray hinting in jpeg reader --------------- */
00066 enum {
00067     L_HINT_GRAY = 1,  /* only want grayscale information */
00068 };
00069 
00070 
00071 /* ------------------ Pdf formated encoding types --------------- */
00072 enum {
00073     L_JPEG_ENCODE   = 1,    /* use dct encoding: 8 and 32 bpp, no cmap     */
00074     L_G4_ENCODE     = 2,    /* use ccitt g4 fax encoding: 1 bpp            */
00075     L_FLATE_ENCODE  = 3     /* use flate encoding: any depth, cmap ok      */
00076 };
00077 
00078 
00079 /* ------------------ Compressed image data --------------------- */
00080 /*
00081  *  In use, either datacomp or data85 will be produced, depending
00082  *  on whether the data needs to be ascii85 encoded.  PostScript
00083  *  requires ascii85 encoding; pdf does not.
00084  *
00085  *  For the colormap (flate compression only), PostScript uses ascii85
00086  *  encoding and pdf uses a bracketed array of space-separated
00087  *  hex-encoded rgb triples.  Only tiff g4 (type == L_G4_ENCODE) uses
00088  *  the minisblack field.
00089  */
00090 struct L_Compressed_Data
00091 {
00092     l_int32            type;         /* encoding type: L_JPEG_ENCODE, etc  */
00093     l_uint8           *datacomp;     /* gzipped raster data                 */
00094     size_t             nbytescomp;   /* number of compressed bytes          */
00095     char              *data85;       /* ascii85-encoded gzipped raster data */
00096     size_t             nbytes85;     /* number of ascii85 encoded bytes     */
00097     char              *cmapdata85;   /* ascii85-encoded uncompressed cmap   */
00098     char              *cmapdatahex;  /* hex pdf array for the cmap          */
00099     l_int32            ncolors;      /* number of colors in cmap            */
00100     l_int32            w;            /* image width                         */
00101     l_int32            h;            /* image height                        */
00102     l_int32            bps;          /* bits/sample; typ. 1, 2, 4 or 8      */
00103     l_int32            spp;          /* samples/pixel; typ. 1 or 3          */
00104     l_int32            minisblack;   /* tiff g4 photometry                  */
00105     size_t             nbytes;       /* number of uncompressed raster bytes */
00106     l_int32            res;          /* resolution (ppi)                    */
00107 };
00108 typedef struct L_Compressed_Data  L_COMPRESSED_DATA;
00109 
00110 
00111 /* ------------------------ Pdf multi-image flags ------------------------ */
00112 enum {
00113     L_FIRST_IMAGE   = 1,    /* first image to be used                      */
00114     L_NEXT_IMAGE    = 2,    /* intermediate image; not first or last       */
00115     L_LAST_IMAGE    = 3     /* last image to be used                       */
00116 };
00117 
00118 
00119 /* ------------------ Intermediate pdf generation data -------------------- */
00120 /*
00121  *  This accumulates data for generating a pdf of a single page consisting
00122  *  of an arbitrary number of images.
00123  *
00124  *  None of the strings have a trailing newline.
00125  */
00126 struct L_Pdf_Data
00127 {
00128     char              *title;        /* optional title for pdf              */
00129     l_int32            n;            /* number of images                    */
00130     l_int32            ncmap;        /* number of colormaps                 */
00131     struct L_Ptra     *cida;         /* array of compressed image data      */
00132     char              *id;           /* %PDF-1.2 id string                  */
00133     char              *obj1;         /* catalog string                      */
00134     char              *obj2;         /* metadata string                     */
00135     char              *obj3;         /* pages string                        */
00136     char              *obj4;         /* page string (variable data)         */
00137     char              *obj5;         /* content string (variable data)      */
00138     char              *poststream;   /* post-binary-stream string           */
00139     char              *trailer;      /* trailer string (variable data)      */
00140     struct Pta        *xy;           /* store (xpt, ypt) array              */
00141     struct Pta        *wh;           /* store (wpt, hpt) array              */
00142     struct Box        *mediabox;     /* bounding region for all images      */
00143     struct Sarray     *saprex;       /* pre-binary-stream xobject strings   */
00144     struct Sarray     *sacmap;       /* colormap pdf object strings         */
00145     struct Numa       *objsize;      /* sizes of each pdf string object     */
00146     struct Numa       *objloc;       /* location of each pdf string object  */
00147     l_int32            xrefloc;      /* location of xref                    */
00148 };
00149 typedef struct L_Pdf_Data  L_PDF_DATA;
00150 
00151 
00152 #endif  /* LEPTONICA_IMAGEIO_H */
00153 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines