Debian Codegraph @

texk/web2c/xetexdir/image/jpegimage.h

raw
1 /****************************************************************************\
2 Part of the XeTeX typesetting system
3 Copyright (c) 1994-2006 by SIL International
4
5 SIL Author(s): Jonathan Kew
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20 \****************************************************************************/
21
22 /* this file is derived from the dvipdfmx project;
23 the original header follows... */
24
25 /* $Header: /home/cvsroot/dvipdfmx/src/jpegimage.h,v 1.2 2004/03/11 11:50:21 hirata Exp $
26
27 This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks.
28
29 Copyright (C) 2002 by Jin-Hwan Cho and Shunsaku Hirata,
30 the dvipdfmx project team <[email protected]>
31
32 Copyright (C) 1998, 1999 by Mark A. Wicks <[email protected]>
33
34 This program is free software; you can redistribute it and/or modify
35 it under the terms of the GNU General Public License as published by
36 the Free Software Foundation; either version 2 of the License, or
37 (at your option) any later version.
38
39 This program is distributed in the hope that it will be useful,
40 but WITHOUT ANY WARRANTY; without even the implied warranty of
41 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 GNU General Public License for more details.
43
44 You should have received a copy of the GNU General Public License
45 along with this program; if not, write to the Free Software
46 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
47 */
48
49 #ifndef _JPEGIMAGE_H_
50 #define _JPEGIMAGE_H_
51
52 #include "mfileio.h"
53
54 /* JPEG Markers */
55 typedef enum {
56 JM_SOF0 = 0xc0,
57 JM_SOF1 = 0xc1,
58 JM_SOF2 = 0xc2,
59 JM_SOF3 = 0xc3,
60 JM_SOF5 = 0xc5,
61 JM_DHT = 0xc4,
62 JM_SOF6 = 0xc6,
63 JM_SOF7 = 0xc7,
64 JM_SOF9 = 0xc9,
65 JM_SOF10 = 0xca,
66 JM_SOF11 = 0xcb,
67 JM_DAC = 0xcc,
68 JM_SOF13 = 0xcd,
69 JM_SOF14 = 0xce,
70 JM_SOF15 = 0xcf,
71
72 JM_RST0 = 0xd0,
73 JM_RST1 = 0xd1,
74 JM_RST2 = 0xd2,
75 JM_RST3 = 0xd3,
76 JM_RST4 = 0xd4,
77 JM_RST5 = 0xd5,
78 JM_RST6 = 0xd6,
79 JM_RST7 = 0xd7,
80
81 JM_SOI = 0xd8,
82 JM_EOI = 0xd9,
83 JM_SOS = 0xda,
84 JM_DQT = 0xdb,
85 JM_DNL = 0xdc,
86 JM_DRI = 0xdd,
87 JM_DHP = 0xde,
88 JM_EXP = 0xdf,
89
90 JM_APP0 = 0xe0,
91 JM_APP1 = 0xe1,
92 JM_APP2 = 0xe2,
93 JM_APP14 = 0xee,
94 JM_APP15 = 0xef,
95
96 JM_COM = 0xfe
97 } JPEG_marker;
98
99 typedef enum {
100 JS_APPn_JFIF,
101 JS_APPn_ADOBE,
102 JS_APPn_ICC
103 } JPEG_APPn_sig;
104
105 struct JPEG_APPn_JFIF /* APP0 */
106 {
107 unsigned short version;
108 unsigned char units; /* 0: only aspect ratio
109 * 1: dots per inch
110 * 2: dots per cm
111 */
112 unsigned short Xdensity;
113 unsigned short Ydensity;
114 unsigned char Xthumbnail;
115 unsigned char Ythumbnail;
116 unsigned char *thumbnail; /* Thumbnail data. */
117 };
118
119 struct JPEG_APPn_ICC /* APP2 */
120 {
121 unsigned char seq_id;
122 unsigned char num_chunks;
123 unsigned char *chunk;
124
125 /* Length of ICC profile data in this chunk. */
126 unsigned short length;
127 };
128
129 struct JPEG_APPn_Adobe /* APP14 */
130 {
131 unsigned short version;
132 unsigned short flag0;
133 unsigned short flag1;
134 unsigned char transform; /* color transform code */
135 };
136
137 struct JPEG_ext
138 {
139 JPEG_marker marker;
140 JPEG_APPn_sig app_sig;
141 void *app_data;
142 };
143
144 #define MAX_COUNT 1024
145 struct JPEG_info
146 {
147 unsigned short height;
148 unsigned short width;
149
150 unsigned char bits_per_component;
151 unsigned char num_components;
152
153 double xdpi;
154 double ydpi;
155
156 /* Application specific extensions */
157 int flags;
158 int num_appn, max_appn;
159 struct JPEG_ext *appn;
160
161 /* Skip chunks not necessary. */
162 char skipbits[MAX_COUNT / 8 + 1];
163 };
164
165 extern int check_for_jpeg(FILE *fp);
166 extern int JPEG_scan_file(struct JPEG_info *info, FILE *fp);
167
168 #endif /* _JPEGIMAGE_H_ */