Leptonica  1.73
Image processing and image analysis suite
imageio.h
Go to the documentation of this file.
1 /*====================================================================*
2  - Copyright (C) 2001 Leptonica. All rights reserved.
3  -
4  - Redistribution and use in source and binary forms, with or without
5  - modification, are permitted provided that the following conditions
6  - are met:
7  - 1. Redistributions of source code must retain the above copyright
8  - notice, this list of conditions and the following disclaimer.
9  - 2. Redistributions in binary form must reproduce the above
10  - copyright notice, this list of conditions and the following
11  - disclaimer in the documentation and/or other materials
12  - provided with the distribution.
13  -
14  - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANY
18  - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22  - OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *====================================================================*/
26 
70 #ifndef LEPTONICA_IMAGEIO_H
71 #define LEPTONICA_IMAGEIO_H
72 
73 /* --------------------------------------------------------------- *
74  * Image file format types *
75  * --------------------------------------------------------------- */
76 /*
77  * The IFF_DEFAULT flag is used to write the file out in the
78  * same (input) file format that the pix was read from. If the pix
79  * was not read from file, the input format field will be
80  * IFF_UNKNOWN and the output file format will be chosen to
81  * be compressed and lossless; namely, IFF_TIFF_G4 for d = 1
82  * and IFF_PNG for everything else.
83  *
84  * In the future, new format types that have defined extensions
85  * will be added before IFF_DEFAULT, and will be kept in sync with
86  * the file format extensions in writefile.c. The positions of
87  * file formats before IFF_DEFAULT will remain invariant.
88  */
89 
91 enum {
92  IFF_UNKNOWN = 0,
93  IFF_BMP = 1,
94  IFF_JFIF_JPEG = 2,
95  IFF_PNG = 3,
96  IFF_TIFF = 4,
97  IFF_TIFF_PACKBITS = 5,
98  IFF_TIFF_RLE = 6,
99  IFF_TIFF_G3 = 7,
100  IFF_TIFF_G4 = 8,
101  IFF_TIFF_LZW = 9,
102  IFF_TIFF_ZIP = 10,
103  IFF_PNM = 11,
104  IFF_PS = 12,
105  IFF_GIF = 13,
106  IFF_JP2 = 14,
107  IFF_WEBP = 15,
108  IFF_LPDF = 16,
109  IFF_DEFAULT = 17,
110  IFF_SPIX = 18
111 };
112 
113 
114 /* --------------------------------------------------------------- *
115  * Format header ids *
116  * --------------------------------------------------------------- */
117 
119 enum {
120  BMP_ID = 0x4d42,
121  TIFF_BIGEND_ID = 0x4d4d,
123 };
124 
125 
126 /* --------------------------------------------------------------- *
127  * Hinting bit flags in jpeg reader *
128  * --------------------------------------------------------------- */
129 
131 enum {
134 };
135 
136 
137 /* --------------------------------------------------------------- *
138  * Pdf formatted encoding types *
139  * --------------------------------------------------------------- */
140 
142 enum {
148 };
149 
150 
151 /* --------------------------------------------------------------- *
152  * Compressed image data *
153  * --------------------------------------------------------------- */
154 /*
155  * In use, either datacomp or data85 will be produced, depending
156  * on whether the data needs to be ascii85 encoded. PostScript
157  * requires ascii85 encoding; pdf does not.
158  *
159  * For the colormap (flate compression only), PostScript uses ascii85
160  * encoding and pdf uses a bracketed array of space-separated
161  * hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
162  * the minisblack field.
163  */
164 
167 {
168  l_int32 type;
169  l_uint8 *datacomp;
170  size_t nbytescomp;
171  char *data85;
172  size_t nbytes85;
173  char *cmapdata85;
174  char *cmapdatahex;
175  l_int32 ncolors;
176  l_int32 w;
177  l_int32 h;
178  l_int32 bps;
179  l_int32 spp;
180  l_int32 minisblack;
181  l_int32 predictor;
182  size_t nbytes;
183  l_int32 res;
184 };
185 typedef struct L_Compressed_Data L_COMP_DATA;
186 
187 
188 /* ------------------------------------------------------------------------- *
189  * Pdf multi image flags *
190  * ------------------------------------------------------------------------- */
191 
193 enum {
197 };
198 
199 
200 /* ------------------------------------------------------------------------- *
201  * Intermediate pdf generation data *
202  * ------------------------------------------------------------------------- */
203 /*
204  * This accumulates data for generating a pdf of a single page consisting
205  * of an arbitrary number of images.
206  *
207  * None of the strings have a trailing newline.
208  */
209 
212 {
213  char *title;
214  l_int32 n;
215  l_int32 ncmap;
216  struct L_Ptra *cida;
217  char *id;
218  char *obj1;
219  char *obj2;
220  char *obj3;
221  char *obj4;
222  char *obj5;
223  char *poststream;
224  char *trailer;
225  struct Pta *xy;
226  struct Pta *wh;
227  struct Box *mediabox;
228  struct Sarray *saprex;
229  struct Sarray *sacmap;
230  struct L_Dna *objsize;
231  struct L_Dna *objloc;
232  l_int32 xrefloc;
233 };
234 typedef struct L_Pdf_Data L_PDF_DATA;
235 
236 
237 #endif /* LEPTONICA_IMAGEIO_H */
struct Sarray * saprex
Definition: imageio.h:228
l_int32 ncolors
Definition: imageio.h:175
l_int32 predictor
Definition: imageio.h:181
char * cmapdata85
Definition: imageio.h:173
struct L_Ptra * cida
Definition: imageio.h:216
char * trailer
Definition: imageio.h:224
Definition: array.h:83
size_t nbytes85
Definition: imageio.h:172
Definition: array.h:116
struct L_Dna * objsize
Definition: imageio.h:230
l_int32 type
Definition: imageio.h:168
char * id
Definition: imageio.h:217
l_int32 xrefloc
Definition: imageio.h:232
Definition: ptra.h:51
l_uint8 * datacomp
Definition: imageio.h:169
char * obj3
Definition: imageio.h:220
char * obj5
Definition: imageio.h:222
struct Pta * xy
Definition: imageio.h:225
l_int32 n
Definition: imageio.h:214
char * cmapdatahex
Definition: imageio.h:174
char * obj4
Definition: imageio.h:221
char * poststream
Definition: imageio.h:223
struct Pta * wh
Definition: imageio.h:226
struct Sarray * sacmap
Definition: imageio.h:229
char * title
Definition: imageio.h:213
l_int32 minisblack
Definition: imageio.h:180
char * obj1
Definition: imageio.h:218
char * obj2
Definition: imageio.h:219
struct L_Dna * objloc
Definition: imageio.h:231
l_int32 ncmap
Definition: imageio.h:215
Definition: pix.h:480
struct Box * mediabox
Definition: imageio.h:227
Definition: pix.h:517
size_t nbytescomp
Definition: imageio.h:170