/[public]/psiconv/trunk/lib/psiconv/generate_image.c
ViewVC logotype

Diff of /psiconv/trunk/lib/psiconv/generate_image.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 176 Revision 196
1/* 1/*
2
3 generate_image.c - Part of psiconv, a PSION 5 file formats converter 2 generate_image.c - Part of psiconv, a PSION 5 file formats converter
4 Copyright (c) 1999, 2000 Frodo Looijaard <frodol@dds.nl> 3 Copyright (c) 1999-2004 Frodo Looijaard <frodol@dds.nl>
5 4
6 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version. 8 (at your option) any later version.
22#include "compat.h" 21#include "compat.h"
23 22
24#include "generate_routines.h" 23#include "generate_routines.h"
25#include "error.h" 24#include "error.h"
26#include "list.h" 25#include "list.h"
26#include "image.h"
27 27
28#ifdef DMALLOC 28#ifdef DMALLOC
29#include <dmalloc.h> 29#include <dmalloc.h>
30#endif 30#endif
31 31
32typedef psiconv_list psiconv_pixel_bytes; /* psiconv_u8 */
33
34typedef psiconv_list psiconv_pixel_ints; /* of psiconv_u32 */
35
36typedef struct psiconv_pixel_float_s
37{
38 psiconv_u32 length;
39 float *red;
40 float *green;
41 float *blue;
42} psiconv_pixel_floats_t;
43 32
44static int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels, 33static int psiconv_collect_pixel_data(psiconv_pixel_ints *pixels,
45 int xsize,int ysize, 34 int xsize,int ysize,
46 const psiconv_pixel_floats_t data, 35 const psiconv_pixel_floats_t data,
47 int colordepth,int color, 36 int colordepth,int color,
62 psiconv_pixel_bytes *encoded_bytes); 51 psiconv_pixel_bytes *encoded_bytes);
63static int psiconv_encode_rle24(const psiconv_config config, 52static int psiconv_encode_rle24(const psiconv_config config,
64 const psiconv_pixel_bytes plain_bytes, 53 const psiconv_pixel_bytes plain_bytes,
65 psiconv_pixel_bytes *encoded_bytes); 54 psiconv_pixel_bytes *encoded_bytes);
66 55
67#define PALET_NONE_LEN 0
68
69psiconv_pixel_floats_t palet_none =
70 {
71 PALET_NONE_LEN,
72 NULL,
73 NULL,
74 NULL
75 };
76
77#define PALET_COLOR_4_LEN 16
78float palet_color_4_red[PALET_COLOR_4_LEN] =
79 { 0x00/256.0, 0x55/256.0, 0x80/256.0, 0x80/256.0, /* 0x00 */
80 0x00/256.0, 0xff/256.0, 0x00/256.0, 0xff/256.0, /* 0x04 */
81 0xff/256.0, 0x00/256.0, 0x00/256.0, 0x80/256.0, /* 0x08 */
82 0x00/256.0, 0x00/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
83 };
84
85float palet_color_4_green[PALET_COLOR_4_LEN] =
86 { 0x00/256.0, 0x55/256.0, 0x00/256.0, 0x80/256.0, /* 0x00 */
87 0x80/256.0, 0x00/256.0, 0xff/256.0, 0xff/256.0, /* 0x04 */
88 0x00/256.0, 0xff/256.0, 0xff/256.0, 0x00/256.0, /* 0x08 */
89 0x00/256.0, 0x80/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
90 };
91
92float palet_color_4_blue[PALET_COLOR_4_LEN] =
93 { 0x00/256.0, 0x55/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
94 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x04 */
95 0xff/256.0, 0x00/256.0, 0xff/256.0, 0x80/256.0, /* 0x08 */
96 0x80/256.0, 0x80/256.0, 0xaa/256.0, 0xff/256.0 /* 0x0c */
97 };
98
99psiconv_pixel_floats_t palet_color_4 =
100 {
101 PALET_COLOR_4_LEN,
102 palet_color_4_red,
103 palet_color_4_green,
104 palet_color_4_blue,
105 };
106
107#define PALET_COLOR_8_LEN 256
108float palet_color_8_red[PALET_COLOR_8_LEN] =
109 { 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x00 */
110 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x04 */
111 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x08 */
112 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x0c */
113 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x10 */
114 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x14 */
115 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x18 */
116 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x1c */
117 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x20 */
118 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x24 */
119 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x28 */
120 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x2c */
121 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x30 */
122 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x34 */
123 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x38 */
124 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x3c */
125 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x40 */
126 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x44 */
127 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x48 */
128 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x4c */
129 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x50 */
130 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x54 */
131 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x58 */
132 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x5c */
133 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x60 */
134 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x64 */
135 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x68 */
136 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
137 0x77/256.0, 0x11/256.0, 0x22/256.0, 0x44/256.0, /* 0x70 */
138 0x55/256.0, 0x77/256.0, 0x00/256.0, 0x00/256.0, /* 0x74 */
139 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x78 */
140 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x7c */
141 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x80 */
142 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x84 */
143 0x00/256.0, 0x00/256.0, 0x88/256.0, 0xaa/256.0, /* 0x88 */
144 0xbb/256.0, 0xdd/256.0, 0xee/256.0, 0x88/256.0, /* 0x8c */
145 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
146 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0x94 */
147 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0x98 */
148 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0x9c */
149 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xa0 */
150 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xa4 */
151 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xa8 */
152 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xac */
153 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xb0 */
154 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xb4 */
155 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xb8 */
156 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xbc */
157 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xc0 */
158 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xc4 */
159 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xc8 */
160 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xcc */
161 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xd0 */
162 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xd4 */
163 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xd8 */
164 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xdc */
165 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xe0 */
166 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xe4 */
167 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xe8 */
168 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xec */
169 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0, /* 0xf0 */
170 0x00/256.0, 0x33/256.0, 0x66/256.0, 0x99/256.0, /* 0xf4 */
171 0xcc/256.0, 0xff/256.0, 0x00/256.0, 0x33/256.0, /* 0xf8 */
172 0x66/256.0, 0x99/256.0, 0xcc/256.0, 0xff/256.0 /* 0xfc */
173 };
174
175float palet_color_8_green[PALET_COLOR_8_LEN] =
176 { 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
177 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x04 */
178 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x08 */
179 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x0c */
180 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x10 */
181 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x14 */
182 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x18 */
183 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x1c */
184 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x20 */
185 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x24 */
186 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x28 */
187 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x2c */
188 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x30 */
189 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x34 */
190 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x38 */
191 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x3c */
192 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x40 */
193 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x44 */
194 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x48 */
195 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x4c */
196 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x50 */
197 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x54 */
198 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0x58 */
199 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x5c */
200 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0x60 */
201 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0x64 */
202 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0x68 */
203 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
204 0x77/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x70 */
205 0x00/256.0, 0x00/256.0, 0x11/256.0, 0x22/256.0, /* 0x74 */
206 0x44/256.0, 0x55/256.0, 0x77/256.0, 0x00/256.0, /* 0x78 */
207 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x7c */
208 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x80 */
209 0x00/256.0, 0x88/256.0, 0xaa/256.0, 0xbb/256.0, /* 0x84 */
210 0xdd/256.0, 0xee/256.0, 0x00/256.0, 0x00/256.0, /* 0x88 */
211 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x88/256.0, /* 0x8c */
212 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
213 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x94 */
214 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0x98 */
215 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x9c */
216 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xa0 */
217 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xa4 */
218 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa8 */
219 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xac */
220 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xb0 */
221 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xb4 */
222 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0xb8 */
223 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0xbc */
224 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0xc0 */
225 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xc4 */
226 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xc8 */
227 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xcc */
228 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd0 */
229 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xd4 */
230 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xd8 */
231 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0xdc */
232 0x00/256.0, 0x00/256.0, 0x33/256.0, 0x33/256.0, /* 0xe0 */
233 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0xe4 */
234 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0xe8 */
235 0x66/256.0, 0x66/256.0, 0x99/256.0, 0x99/256.0, /* 0xec */
236 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xf0 */
237 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xf4 */
238 0xcc/256.0, 0xcc/256.0, 0xff/256.0, 0xff/256.0, /* 0xf8 */
239 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xfc */
240 };
241
242float palet_color_8_blue[PALET_COLOR_8_LEN] =
243 { 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x00 */
244 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x04 */
245 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x08 */
246 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x0c */
247 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x10 */
248 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x14 */
249 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x18 */
250 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x1c */
251 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x20 */
252 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x24 */
253 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x28 */
254 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x2c */
255 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x30 */
256 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x34 */
257 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x38 */
258 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x3c */
259 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x40 */
260 0x33/256.0, 0x33/256.0, 0x33/256.0, 0x33/256.0, /* 0x44 */
261 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x48 */
262 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x4c */
263 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x50 */
264 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x54 */
265 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x58 */
266 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x5c */
267 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x60 */
268 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x64 */
269 0x66/256.0, 0x66/256.0, 0x66/256.0, 0x66/256.0, /* 0x68 */
270 0x11/256.0, 0x22/256.0, 0x44/256.0, 0x55/256.0, /* 0x6c */
271 0x77/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x70 */
272 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x74 */
273 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x11/256.0, /* 0x78 */
274 0x22/256.0, 0x44/256.0, 0x55/256.0, 0x77/256.0, /* 0x7c */
275 0x88/256.0, 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, /* 0x80 */
276 0xee/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x84 */
277 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x00/256.0, /* 0x88 */
278 0x00/256.0, 0x00/256.0, 0x00/256.0, 0x88/256.0, /* 0x8c */
279 0xaa/256.0, 0xbb/256.0, 0xdd/256.0, 0xee/256.0, /* 0x90 */
280 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x94 */
281 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x98 */
282 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0x9c */
283 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa0 */
284 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa4 */
285 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xa8 */
286 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xac */
287 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xb0 */
288 0x99/256.0, 0x99/256.0, 0x99/256.0, 0x99/256.0, /* 0xb4 */
289 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xb8 */
290 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xbc */
291 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc0 */
292 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc4 */
293 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xc8 */
294 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xcc */
295 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd0 */
296 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd4 */
297 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, 0xcc/256.0, /* 0xd8 */
298 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xdc */
299 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe0 */
300 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe4 */
301 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xe8 */
302 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xec */
303 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf0 */
304 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf4 */
305 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xf8 */
306 0xff/256.0, 0xff/256.0, 0xff/256.0, 0xff/256.0, /* 0xfc */
307 };
308
309psiconv_pixel_floats_t palet_color_8 =
310 {
311 PALET_COLOR_8_LEN,
312 palet_color_8_red,
313 palet_color_8_green,
314 palet_color_8_blue,
315 };
316
317int psiconv_write_paint_data_section(const psiconv_config config, 56int psiconv_write_paint_data_section(const psiconv_config config,
318 psiconv_buffer buf, 57 psiconv_buffer buf, int lev,
319 const psiconv_paint_data_section value, 58 const psiconv_paint_data_section value,
320 int is_clipart) 59 int is_clipart)
321{ 60{
322 int res,colordepth,i; 61 int res,colordepth,i;
323 psiconv_pixel_ints ints; 62 psiconv_pixel_ints ints;
324 psiconv_pixel_floats_t floats,palet; 63 psiconv_pixel_floats_t floats,palet;
325 psiconv_list bytes,bytes_rle; 64 psiconv_list bytes,bytes_rle;
326 psiconv_u8 *byteptr,encoding; 65 psiconv_u8 *byteptr,encoding;
327 66
67 psiconv_progress(config,lev,0,"Writing paint data section");
68
328 /* First, we check whether we can cope with the current configuration. 69 /* First, we check whether we can cope with the current configuration.
329 If not, we stop at once */ 70 If not, we stop at once */
330 if ((config->colordepth != 2) && (config->colordepth != 4) && 71 if ((config->colordepth != 2) && (config->colordepth != 4) &&
331 (config->colordepth != 8) && (config->colordepth != 12) && 72 (config->colordepth != 8) && (config->colordepth != 12) &&
332 (config->colordepth != 16) && (config->colordepth != 24)) { 73 (config->colordepth != 16) && (config->colordepth != 24)) {
333 psiconv_warn(config,0,psiconv_buffer_length(buf), 74 psiconv_error(config,0,psiconv_buffer_length(buf),
334 "Unsupported color depth (%d); try 2, 4, 8, 16 or 24", 75 "Unsupported color depth (%d); try 2, 4, 8, 16 or 24",
335 config->colordepth); 76 config->colordepth);
336 res = -PSICONV_E_GENERATE; 77 res = -PSICONV_E_GENERATE;
337 goto ERROR1; 78 goto ERROR1;
338 } 79 }
339 80
340 if ((config->color) && 81 if ((config->color) &&
341 (config->bluebits || config->redbits || config->greenbits) && 82 (config->bluebits || config->redbits || config->greenbits) &&
342 (config->bluebits+config->redbits+config->greenbits!=config->colordepth)) { 83 (config->bluebits+config->redbits+config->greenbits!=config->colordepth)) {
343 psiconv_warn(config,0,psiconv_buffer_length(buf), 84 psiconv_error(config,0,psiconv_buffer_length(buf),
344 "Sum of red (%d), green (%d) and blue (%d) bits should be " 85 "Sum of red (%d), green (%d) and blue (%d) bits should be "
345 "equal to the color depth (%d)", 86 "equal to the color depth (%d)",
346 config->redbits,config->greenbits,config->bluebits, 87 config->redbits,config->greenbits,config->bluebits,
347 config->colordepth); 88 config->colordepth);
348 res = -PSICONV_E_GENERATE; 89 res = -PSICONV_E_GENERATE;
350 } 91 }
351 92
352 if (config->color && 93 if (config->color &&
353 !(config->redbits || config->greenbits || config->bluebits) && 94 !(config->redbits || config->greenbits || config->bluebits) &&
354 (config->colordepth != 4) && (config->colordepth != 8)) { 95 (config->colordepth != 4) && (config->colordepth != 8)) {
355 psiconv_warn(config,0,psiconv_buffer_length(buf), 96 psiconv_error(config,0,psiconv_buffer_length(buf),
356 "Current color depth (%d) has no palet associated with it", 97 "Current color depth (%d) has no palet associated with it",
357 config->colordepth); 98 config->colordepth);
358 res = -PSICONV_E_GENERATE; 99 res = -PSICONV_E_GENERATE;
359 goto ERROR1; 100 goto ERROR1;
360 } 101 }
363 psiconv_warn(config,0,psiconv_buffer_length(buf), 104 psiconv_warn(config,0,psiconv_buffer_length(buf),
364 "All image types except 2-bit greyscale are experimental!"); 105 "All image types except 2-bit greyscale are experimental!");
365 106
366 107
367 if (!value) { 108 if (!value) {
368 psiconv_warn(config,0,psiconv_buffer_length(buf),"Null paint data section"); 109 psiconv_error(config,0,psiconv_buffer_length(buf),"Null paint data section");
369 res = -PSICONV_E_GENERATE; 110 res = -PSICONV_E_GENERATE;
370 goto ERROR1; 111 goto ERROR1;
371 } 112 }
372 113
373 floats.red = value->red; 114 floats.red = value->red;
374 floats.green = value->green; 115 floats.green = value->green;
375 floats.blue = value->blue; 116 floats.blue = value->blue;
376 floats.length = value->xsize * value->ysize; 117 floats.length = value->xsize * value->ysize;
377 118
378 palet = palet_none; 119 palet = psiconv_palet_none;
379 if ((config->color) && (config->redbits == 0) && (config->greenbits == 0) &&\ 120 if ((config->color) && (config->redbits == 0) && (config->greenbits == 0) &&
380 (config->bluebits == 0)) 121 (config->bluebits == 0))
381 switch (config->colordepth) { 122 switch (config->colordepth) {
382 case 4: palet = palet_color_4; break; 123 case 4: palet = psiconv_palet_color_4; break;
383 case 8: palet = palet_color_8; break; 124 case 8: palet = psiconv_palet_color_8; break;
384 default: palet = palet_none; break; 125 default: palet = psiconv_palet_none; break;
385 } 126 }
386 127
387 if ((res = psiconv_collect_pixel_data(&ints,value->xsize, 128 if ((res = psiconv_collect_pixel_data(&ints,value->xsize,
388 value->ysize,floats, 129 value->ysize,floats,
389 config->colordepth,config->color, 130 config->colordepth,config->color,
390 config->redbits,config->greenbits, 131 config->redbits,config->greenbits,
391 config->bluebits,palet))) 132 config->bluebits,palet))) {
133 psiconv_error(config,lev,0,"Error collecting pixel data");
392 goto ERROR1; 134 goto ERROR1;
135 }
393 136
394 if ((res = psiconv_pixel_data_to_bytes(config,&bytes,value->xsize,value->ysize, 137 if ((res = psiconv_pixel_data_to_bytes(config,&bytes,value->xsize,value->ysize,
395 ints,config->colordepth))) 138 ints,config->colordepth))) {
139 psiconv_error(config,lev,0,"Error translating pixel data to bytes");
396 goto ERROR2; 140 goto ERROR2;
141 }
397 142
398 143
399 switch (config->colordepth) { 144 switch (config->colordepth) {
400 case 2: 145 case 2:
401 case 4: 146 case 4:
402 case 8: 147 case 8:
403 encoding = 0x01; 148 encoding = 0x01;
404 if ((res = psiconv_encode_rle8(config,bytes,&bytes_rle))) 149 if ((res = psiconv_encode_rle8(config,bytes,&bytes_rle))) {
150 psiconv_error(config,lev,0,"Error encoding RLE8");
405 goto ERROR3; 151 goto ERROR3;
152 }
406 break; 153 break;
407 case 12: 154 case 12:
408 encoding = 0x02; 155 encoding = 0x02;
409 if ((res = psiconv_encode_rle12(config,bytes,&bytes_rle))) 156 if ((res = psiconv_encode_rle12(config,bytes,&bytes_rle))) {
157 psiconv_error(config,lev,0,"Error encoding RLE12");
410 goto ERROR3; 158 goto ERROR3;
159 }
411 break; 160 break;
412 case 16: 161 case 16:
413 encoding = 0x03; 162 encoding = 0x03;
414 if ((res = psiconv_encode_rle16(config,bytes,&bytes_rle))) 163 if ((res = psiconv_encode_rle16(config,bytes,&bytes_rle))) {
164 psiconv_error(config,lev,0,"Error encoding RLE16");
415 goto ERROR3; 165 goto ERROR3;
166 }
416 break; 167 break;
417 case 24: 168 case 24:
418 encoding = 0x04; 169 encoding = 0x04;
419 if ((res = psiconv_encode_rle24(config,bytes,&bytes_rle))) 170 if ((res = psiconv_encode_rle24(config,bytes,&bytes_rle))) {
171 psiconv_error(config,lev,0,"Error encoding RLE24");
420 goto ERROR3; 172 goto ERROR3;
173 }
421 break; 174 break;
422 default: 175 default:
423 encoding = 0x00; 176 encoding = 0x00;
424 } 177 }
425 if (encoding) { 178 if (encoding) {
430 psiconv_list_free(bytes_rle); 183 psiconv_list_free(bytes_rle);
431 encoding = 0x00; 184 encoding = 0x00;
432 } 185 }
433 } 186 }
434 187
435 if ((res = psiconv_write_u32(config,buf, 188 if ((res = psiconv_write_u32(config,buf,lev+1,
436 0x28+psiconv_list_length(bytes)))) 189 0x28+psiconv_list_length(bytes))))
437 goto ERROR3; 190 goto ERROR3;
438 if ((res = psiconv_write_u32(config,buf,0x28))) 191 if ((res = psiconv_write_u32(config,buf,lev+1,0x28)))
439 goto ERROR3; 192 goto ERROR3;
440 if ((res = psiconv_write_u32(config,buf,value->xsize))) 193 if ((res = psiconv_write_u32(config,buf,lev+1,value->xsize)))
441 goto ERROR3; 194 goto ERROR3;
442 if ((res = psiconv_write_u32(config,buf,value->ysize))) 195 if ((res = psiconv_write_u32(config,buf,lev+1,value->ysize)))
443 goto ERROR3; 196 goto ERROR3;
444 if ((res = psiconv_write_length(config,buf,value->pic_xsize))) 197 if ((res = psiconv_write_length(config,buf,lev+1,value->pic_xsize)))
445 goto ERROR3; 198 goto ERROR3;
446 if ((res = psiconv_write_length(config,buf,value->pic_ysize))) 199 if ((res = psiconv_write_length(config,buf,lev+1,value->pic_ysize)))
447 goto ERROR3; 200 goto ERROR3;
448 colordepth = config->colordepth; 201 colordepth = config->colordepth;
449 if ((res = psiconv_write_u32(config,buf,colordepth))) 202 if ((res = psiconv_write_u32(config,buf,lev+1,colordepth)))
450 goto ERROR3; 203 goto ERROR3;
451 if ((res = psiconv_write_u32(config,buf,(config->color?1:0)))) 204 if ((res = psiconv_write_u32(config,buf,lev+1,(config->color?1:0))))
452 goto ERROR3; 205 goto ERROR3;
453 if ((res = psiconv_write_u32(config,buf,0))) 206 if ((res = psiconv_write_u32(config,buf,lev+1,0)))
454 goto ERROR3; 207 goto ERROR3;
455 if ((res = psiconv_write_u32(config,buf,encoding))) 208 if ((res = psiconv_write_u32(config,buf,lev+1,encoding)))
456 goto ERROR3; 209 goto ERROR3;
457 if (is_clipart) { 210 if (is_clipart) {
458 if ((res = psiconv_write_u32(config,buf,0xffffffff))) 211 if ((res = psiconv_write_u32(config,buf,lev+1,0xffffffff)))
459 goto ERROR3; 212 goto ERROR3;
460 if ((res = psiconv_write_u32(config,buf,0x00000044))) 213 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000044)))
461 goto ERROR3; 214 goto ERROR3;
462 } 215 }
463 for (i = 0; i < psiconv_list_length(bytes); i++) { 216 for (i = 0; i < psiconv_list_length(bytes); i++) {
464 if (!(byteptr = psiconv_list_get(bytes,i))) 217 if (!(byteptr = psiconv_list_get(bytes,i)))
465 goto ERROR3; 218 goto ERROR3;
466 if ((res = psiconv_write_u8(config,buf,*byteptr))) 219 if ((res = psiconv_write_u8(config,buf,lev+1,*byteptr)))
467 goto ERROR3; 220 goto ERROR3;
468 } 221 }
469 222
470ERROR3: 223ERROR3:
471 psiconv_list_free(bytes); 224 psiconv_list_free(bytes);
547 psiconv_u32 *pixelptr; 300 psiconv_u32 *pixelptr;
548 int inputbitsleft,outputbitnr,bitsfit,outputbytenr; 301 int inputbitsleft,outputbitnr,bitsfit,outputbytenr;
549 302
550 303
551 if (!bytes) { 304 if (!bytes) {
552 psiconv_warn(config,0,0,"NULL pixel data"); 305 psiconv_error(config,0,0,"NULL pixel data");
553 res = -PSICONV_E_GENERATE; 306 res = -PSICONV_E_GENERATE;
554 goto ERROR1; 307 goto ERROR1;
555 } 308 }
556 if (!pixels) { 309 if (!pixels) {
557 psiconv_warn(config,0,0,"NULL pixel data"); 310 psiconv_error(config,0,0,"NULL pixel data");
558 res = -PSICONV_E_GENERATE; 311 res = -PSICONV_E_GENERATE;
559 goto ERROR1; 312 goto ERROR1;
560 } 313 }
561 if (psiconv_list_length(pixels) != xsize * ysize) { 314 if (psiconv_list_length(pixels) != xsize * ysize) {
562 psiconv_warn(config,0,0,"Pixel number is not correct"); 315 psiconv_error(config,0,0,"Pixel number is not correct");
563 res = -PSICONV_E_GENERATE; 316 res = -PSICONV_E_GENERATE;
564 goto ERROR1; 317 goto ERROR1;
565 } 318 }
566 319
567 if (!(*bytes = psiconv_list_new(sizeof(psiconv_u8)))) { 320 if (!(*bytes = psiconv_list_new(sizeof(psiconv_u8)))) {
574 outputbyte = 0; 327 outputbyte = 0;
575 for (y = 0; y < ysize; y++) { 328 for (y = 0; y < ysize; y++) {
576 outputbytenr = 0; 329 outputbytenr = 0;
577 for (x = 0; x < xsize; x++) { 330 for (x = 0; x < xsize; x++) {
578 if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) { 331 if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) {
579 psiconv_warn(config,0,0,"Massive internal corruption"); 332 psiconv_error(config,0,0,"Massive internal corruption");
580 res = -PSICONV_E_NOMEM; 333 res = -PSICONV_E_NOMEM;
581 goto ERROR2; 334 goto ERROR2;
582 } 335 }
583 inputbitsleft = colordepth; 336 inputbitsleft = colordepth;
584 inputdata = *pixelptr; 337 inputdata = *pixelptr;
655 goto ERROR2; 408 goto ERROR2;
656 if ((res = psiconv_list_add(*encoded_bytes,next))) 409 if ((res = psiconv_list_add(*encoded_bytes,next)))
657 goto ERROR2; 410 goto ERROR2;
658 i +=2; 411 i +=2;
659 } else if (*next == *entry) { 412 } else if (*next == *entry) {
660 len = 0; 413 len = 1;
661 while ((*next == *entry) && 414 while ((*next == *entry) &&
662 (i+len + 1 < psiconv_list_length(plain_bytes)) && 415 (i+len + 2 < psiconv_list_length(plain_bytes)) &&
663 len < 0x80) { 416 len < 0x80) {
664 len ++; 417 len ++;
665 if (!(next = psiconv_list_get(plain_bytes,i+len))) { 418 if (!(next = psiconv_list_get(plain_bytes,i+len))) {
666 res = -PSICONV_E_NOMEM; 419 res = -PSICONV_E_NOMEM;
667 goto ERROR2; 420 goto ERROR2;
1077 return res; 830 return res;
1078} 831}
1079 832
1080 833
1081int psiconv_write_sketch_section(const psiconv_config config, 834int psiconv_write_sketch_section(const psiconv_config config,
1082 psiconv_buffer buf, 835 psiconv_buffer buf, int lev,
1083 const psiconv_sketch_section value) 836 const psiconv_sketch_section value)
1084{ 837{
1085 int res; 838 int res;
1086 839
840 psiconv_progress(config,lev,0,"Writing sketch section");
1087 if (!value) { 841 if (!value) {
1088 psiconv_warn(config,0,0,"NULL sketch section"); 842 psiconv_error(config,0,0,"NULL sketch section");
1089 res = -PSICONV_E_GENERATE; 843 res = -PSICONV_E_GENERATE;
1090 goto ERROR1; 844 goto ERROR1;
1091 } 845 }
1092 846
1093 if ((res = psiconv_write_u16(config,buf,value->displayed_xsize))) 847 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_xsize)))
1094 goto ERROR1; 848 goto ERROR1;
1095 if ((res = psiconv_write_u16(config,buf,value->displayed_ysize))) 849 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_ysize)))
1096 goto ERROR1; 850 goto ERROR1;
1097 if ((res = psiconv_write_u16(config,buf,value->picture_data_x_offset))) 851 if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_x_offset)))
1098 goto ERROR1; 852 goto ERROR1;
1099 if ((res = psiconv_write_u16(config,buf,value->picture_data_y_offset))) 853 if ((res = psiconv_write_u16(config,buf,lev+1,value->picture_data_y_offset)))
1100 goto ERROR1; 854 goto ERROR1;
1101 if ((res = psiconv_write_u16(config,buf,value->displayed_size_x_offset))) 855 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_x_offset)))
1102 goto ERROR1; 856 goto ERROR1;
1103 if ((res = psiconv_write_u16(config,buf,value->displayed_size_y_offset))) 857 if ((res = psiconv_write_u16(config,buf,lev+1,value->displayed_size_y_offset)))
1104 goto ERROR1; 858 goto ERROR1;
1105 if ((res = psiconv_write_u16(config,buf,value->form_xsize))) 859 if ((res = psiconv_write_u16(config,buf,lev+1,value->form_xsize)))
1106 goto ERROR1; 860 goto ERROR1;
1107 if ((res = psiconv_write_u16(config,buf,value->form_ysize))) 861 if ((res = psiconv_write_u16(config,buf,lev+1,value->form_ysize)))
1108 goto ERROR1; 862 goto ERROR1;
1109 if ((res = psiconv_write_u16(config,buf,0x0000))) 863 if ((res = psiconv_write_u16(config,buf,lev+1,0x0000)))
1110 goto ERROR1; 864 goto ERROR1;
1111 if ((res = psiconv_write_paint_data_section(config,buf,value->picture,0))) 865 if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,0)))
1112 goto ERROR1; 866 goto ERROR1;
1113 if ((res = psiconv_write_u16(config,buf,value->magnification_x * 0x03e8))) 867 if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_x * 0x03e8)))
1114 goto ERROR1; 868 goto ERROR1;
1115 if ((res = psiconv_write_u16(config,buf,value->magnification_y * 0x03e8))) 869 if ((res = psiconv_write_u16(config,buf,lev+1,value->magnification_y * 0x03e8)))
1116 goto ERROR1; 870 goto ERROR1;
1117 if ((res = psiconv_write_u32(config,buf,value->cut_left * 0x0c * 871 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_left * 0x0c *
1118 value->displayed_xsize))) 872 value->displayed_xsize)))
1119 goto ERROR1; 873 goto ERROR1;
1120 if ((res = psiconv_write_u32(config,buf,value->cut_right * 0x0c * 874 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_right * 0x0c *
1121 value->displayed_xsize))) 875 value->displayed_xsize)))
1122 goto ERROR1; 876 goto ERROR1;
1123 if ((res = psiconv_write_u32(config,buf,value->cut_top * 0x0c * 877 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_top * 0x0c *
1124 value->displayed_ysize))) 878 value->displayed_ysize)))
1125 goto ERROR1; 879 goto ERROR1;
1126 if ((res = psiconv_write_u32(config,buf,value->cut_bottom * 0x0c * 880 if ((res = psiconv_write_u32(config,buf,lev+1,value->cut_bottom * 0x0c *
1127 value->displayed_ysize))) 881 value->displayed_ysize)))
1128 goto ERROR1; 882 goto ERROR1;
1129 883
1130ERROR1: 884ERROR1:
1131 return res; 885 return res;
1132} 886}
1133 887
1134int psiconv_write_clipart_section(const psiconv_config config, 888int psiconv_write_clipart_section(const psiconv_config config,
1135 psiconv_buffer buf, 889 psiconv_buffer buf, int lev,
1136 const psiconv_clipart_section value) 890 const psiconv_clipart_section value)
1137{ 891{
1138 int res; 892 int res;
1139 893
1140 894 psiconv_progress(config,lev,0,"Writing clipart section");
1141 if (!value) { 895 if (!value) {
1142 psiconv_warn(config,0,psiconv_buffer_length(buf), 896 psiconv_error(config,0,psiconv_buffer_length(buf),
1143 "NULL Clipart Section"); 897 "NULL Clipart Section");
1144 res = -PSICONV_E_GENERATE; 898 res = -PSICONV_E_GENERATE;
1145 goto ERROR; 899 goto ERROR;
1146 } 900 }
1147 if ((res = psiconv_write_u32(config,buf,PSICONV_ID_CLIPART_ITEM))) 901 if ((res = psiconv_write_u32(config,buf,lev+1,PSICONV_ID_CLIPART_ITEM)))
1148 goto ERROR; 902 goto ERROR;
1149 if ((res = psiconv_write_u32(config,buf,0x00000002))) 903 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000002)))
1150 goto ERROR; 904 goto ERROR;
1151 if ((res = psiconv_write_u32(config,buf,0x00000000))) 905 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
1152 goto ERROR; 906 goto ERROR;
1153 if ((res = psiconv_write_u32(config,buf,0x00000000))) 907 if ((res = psiconv_write_u32(config,buf,lev+1,0x00000000)))
1154 goto ERROR; 908 goto ERROR;
1155 if ((res = psiconv_write_u32(config,buf,0x0000000C))) 909 if ((res = psiconv_write_u32(config,buf,lev+1,0x0000000C)))
1156 goto ERROR; 910 goto ERROR;
1157 if ((res = psiconv_write_paint_data_section(config,buf,value->picture,1))) 911 if ((res = psiconv_write_paint_data_section(config,buf,lev+1,value->picture,1)))
1158 goto ERROR; 912 goto ERROR;
1159 913
1160ERROR: 914ERROR:
1161 return res; 915 return res;
1162} 916}
1163 917
1164int psiconv_write_jumptable_section(const psiconv_config config, 918int psiconv_write_jumptable_section(const psiconv_config config,
1165 psiconv_buffer buf, 919 psiconv_buffer buf, int lev,
1166 const psiconv_jumptable_section value) 920 const psiconv_jumptable_section value)
1167{ 921{
1168 int res,i; 922 int res,i;
1169 psiconv_u32 *offset_ptr; 923 psiconv_u32 *offset_ptr;
1170 924
925 psiconv_progress(config,lev,0,"Writing jumptable section");
1171 926
1172 if (!value) { 927 if (!value) {
1173 psiconv_warn(config,0,psiconv_buffer_length(buf), 928 psiconv_error(config,0,psiconv_buffer_length(buf),
1174 "NULL Jumptable Section"); 929 "NULL Jumptable Section");
1175 res = -PSICONV_E_GENERATE; 930 res = -PSICONV_E_GENERATE;
1176 goto ERROR; 931 goto ERROR;
1177 } 932 }
1178 if ((res = psiconv_write_u32(config,buf,psiconv_list_length(value)))) 933 if ((res = psiconv_write_u32(config,buf,lev+1,psiconv_list_length(value))))
1179 goto ERROR; 934 goto ERROR;
1180 for (i = 0; i < psiconv_list_length(value); i++) { 935 for (i = 0; i < psiconv_list_length(value); i++) {
1181 if (!(offset_ptr = psiconv_list_get(value,i))) { 936 if (!(offset_ptr = psiconv_list_get(value,i))) {
1182 psiconv_warn(config,0,psiconv_buffer_length(buf), 937 psiconv_error(config,0,psiconv_buffer_length(buf),
1183 "Massive memory corruption"); 938 "Massive memory corruption");
1184 res = -PSICONV_E_NOMEM; 939 res = -PSICONV_E_NOMEM;
1185 goto ERROR; 940 goto ERROR;
1186 } 941 }
1187 if ((res = psiconv_write_offset(config,buf,*offset_ptr))) 942 if ((res = psiconv_write_offset(config,buf,lev+1,*offset_ptr)))
1188 goto ERROR; 943 goto ERROR;
1189 } 944 }
1190 945
1191ERROR: 946ERROR:
1192 return res; 947 return res;

Legend:
Removed from v.176  
changed lines
  Added in v.196

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26