Leptonica
1.77.0
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_TIFF_JPEG = 17,
110
IFF_DEFAULT = 18,
111
IFF_SPIX = 19
112
};
113
114
115
/* --------------------------------------------------------------- *
116
* Format header ids *
117
* --------------------------------------------------------------- */
118
120
enum
{
121
BMP_ID
= 0x4d42,
122
TIFF_BIGEND_ID
= 0x4d4d,
123
TIFF_LITTLEEND_ID
= 0x4949
124
};
125
126
127
/* --------------------------------------------------------------- *
128
* Hinting bit flags in jpeg reader *
129
* --------------------------------------------------------------- */
130
132
enum
{
133
L_JPEG_READ_LUMINANCE
= 1,
134
L_JPEG_FAIL_ON_BAD_DATA
= 2
135
};
136
137
138
/* --------------------------------------------------------------- *
139
* Pdf formatted encoding types *
140
* --------------------------------------------------------------- */
141
143
enum
{
144
L_DEFAULT_ENCODE
= 0,
145
L_JPEG_ENCODE
= 1,
146
L_G4_ENCODE
= 2,
147
L_FLATE_ENCODE
= 3,
148
L_JP2K_ENCODE
= 4
149
};
150
151
152
/* --------------------------------------------------------------- *
153
* Compressed image data *
154
* --------------------------------------------------------------- */
155
/*
156
* In use, either datacomp or data85 will be produced, depending
157
* on whether the data needs to be ascii85 encoded. PostScript
158
* requires ascii85 encoding; pdf does not.
159
*
160
* For the colormap (flate compression only), PostScript uses ascii85
161
* encoding and pdf uses a bracketed array of space-separated
162
* hex-encoded rgb triples. Only tiff g4 (type == L_G4_ENCODE) uses
163
* the minisblack field.
164
*/
165
167
struct
L_Compressed_Data
168
{
169
l_int32
type
;
170
l_uint8 *
datacomp
;
171
size_t
nbytescomp
;
172
char
*
data85
;
173
size_t
nbytes85
;
174
char
*
cmapdata85
;
175
char
*
cmapdatahex
;
176
l_int32
ncolors
;
177
l_int32
w
;
178
l_int32
h
;
179
l_int32
bps
;
180
l_int32
spp
;
181
l_int32
minisblack
;
182
l_int32
predictor
;
183
size_t
nbytes
;
184
l_int32
res
;
185
};
186
typedef
struct
L_Compressed_Data
L_COMP_DATA
;
187
188
189
/* ------------------------------------------------------------------------- *
190
* Pdf multi image flags *
191
* ------------------------------------------------------------------------- */
192
194
enum
{
195
L_FIRST_IMAGE
= 1,
196
L_NEXT_IMAGE
= 2,
197
L_LAST_IMAGE
= 3
198
};
199
200
201
/* ------------------------------------------------------------------------- *
202
* Intermediate pdf generation data *
203
* ------------------------------------------------------------------------- */
204
/*
205
* This accumulates data for generating a pdf of a single page consisting
206
* of an arbitrary number of images.
207
*
208
* None of the strings have a trailing newline.
209
*/
210
212
struct
L_Pdf_Data
213
{
214
char
*
title
;
215
l_int32
n
;
216
l_int32
ncmap
;
217
struct
L_Ptra
*
cida
;
218
char
*
id
;
219
char
*
obj1
;
220
char
*
obj2
;
221
char
*
obj3
;
222
char
*
obj4
;
223
char
*
obj5
;
224
char
*
poststream
;
225
char
*
trailer
;
226
struct
Pta
*
xy
;
227
struct
Pta
*
wh
;
228
struct
Box
*
mediabox
;
229
struct
Sarray
*
saprex
;
230
struct
Sarray
*
sacmap
;
231
struct
L_Dna
*
objsize
;
232
struct
L_Dna
*
objloc
;
233
l_int32
xrefloc
;
234
};
235
typedef
struct
L_Pdf_Data
L_PDF_DATA
;
236
237
238
#endif
/* LEPTONICA_IMAGEIO_H */
L_Pdf_Data::saprex
struct Sarray * saprex
Definition:
imageio.h:229
L_Compressed_Data::ncolors
l_int32 ncolors
Definition:
imageio.h:176
L_FLATE_ENCODE
Definition:
imageio.h:147
L_Compressed_Data::predictor
l_int32 predictor
Definition:
imageio.h:182
BMP_ID
Definition:
imageio.h:121
L_Pdf_Data
Definition:
imageio.h:212
L_G4_ENCODE
Definition:
imageio.h:146
L_LAST_IMAGE
Definition:
imageio.h:197
L_Compressed_Data::cmapdata85
char * cmapdata85
Definition:
imageio.h:174
L_Pdf_Data::cida
struct L_Ptra * cida
Definition:
imageio.h:217
TIFF_BIGEND_ID
Definition:
imageio.h:122
L_Pdf_Data::trailer
char * trailer
Definition:
imageio.h:225
L_Dna
Definition:
array.h:83
L_Compressed_Data::w
l_int32 w
Definition:
imageio.h:177
L_NEXT_IMAGE
Definition:
imageio.h:196
L_Compressed_Data::nbytes85
size_t nbytes85
Definition:
imageio.h:173
Sarray
Definition:
array.h:116
L_Pdf_Data::objsize
struct L_Dna * objsize
Definition:
imageio.h:231
L_Compressed_Data::type
l_int32 type
Definition:
imageio.h:169
L_Pdf_Data::id
char * id
Definition:
imageio.h:218
L_Pdf_Data::xrefloc
l_int32 xrefloc
Definition:
imageio.h:233
L_Compressed_Data::res
l_int32 res
Definition:
imageio.h:184
L_Compressed_Data::bps
l_int32 bps
Definition:
imageio.h:179
L_Ptra
Definition:
ptra.h:51
L_JP2K_ENCODE
Definition:
imageio.h:148
L_Compressed_Data::datacomp
l_uint8 * datacomp
Definition:
imageio.h:170
L_Pdf_Data::obj3
char * obj3
Definition:
imageio.h:221
L_Pdf_Data::obj5
char * obj5
Definition:
imageio.h:223
L_Pdf_Data::xy
struct Pta * xy
Definition:
imageio.h:226
L_Pdf_Data::n
l_int32 n
Definition:
imageio.h:215
L_Compressed_Data::h
l_int32 h
Definition:
imageio.h:178
L_Compressed_Data::cmapdatahex
char * cmapdatahex
Definition:
imageio.h:175
L_Pdf_Data::obj4
char * obj4
Definition:
imageio.h:222
L_DEFAULT_ENCODE
Definition:
imageio.h:144
L_Pdf_Data::poststream
char * poststream
Definition:
imageio.h:224
L_FIRST_IMAGE
Definition:
imageio.h:195
L_Pdf_Data::wh
struct Pta * wh
Definition:
imageio.h:227
L_JPEG_READ_LUMINANCE
Definition:
imageio.h:133
L_Pdf_Data::sacmap
struct Sarray * sacmap
Definition:
imageio.h:230
L_Pdf_Data::title
char * title
Definition:
imageio.h:214
L_Compressed_Data::minisblack
l_int32 minisblack
Definition:
imageio.h:181
L_Pdf_Data::obj1
char * obj1
Definition:
imageio.h:219
L_Pdf_Data::obj2
char * obj2
Definition:
imageio.h:220
L_Compressed_Data
Definition:
imageio.h:167
L_Pdf_Data::objloc
struct L_Dna * objloc
Definition:
imageio.h:232
L_Compressed_Data::spp
l_int32 spp
Definition:
imageio.h:180
L_Compressed_Data::nbytes
size_t nbytes
Definition:
imageio.h:183
L_JPEG_ENCODE
Definition:
imageio.h:145
TIFF_LITTLEEND_ID
Definition:
imageio.h:123
L_Pdf_Data::ncmap
l_int32 ncmap
Definition:
imageio.h:216
Box
Definition:
pix.h:480
L_Pdf_Data::mediabox
struct Box * mediabox
Definition:
imageio.h:228
L_JPEG_FAIL_ON_BAD_DATA
Definition:
imageio.h:134
Pta
Definition:
pix.h:517
L_Compressed_Data::nbytescomp
size_t nbytescomp
Definition:
imageio.h:171
L_Compressed_Data::data85
char * data85
Definition:
imageio.h:172
src
imageio.h
Generated by
1.8.14