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

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

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

Revision 12 Revision 13
50 50
51 if (length) 51 if (length)
52 *length = len; 52 *length = len;
53 53
54 psiconv_progress(lev+1,off+len-1,"End of mbm jumptable section " 54 psiconv_progress(lev+1,off+len-1,"End of mbm jumptable section "
55 "(total length: %08x", len); 55 "(total length: %08x)", len);
56 56
57 return res; 57 return res;
58} 58}
59 59
60int psiconv_parse_paint_data_section(const psiconv_buffer buf,int lev, 60int psiconv_parse_paint_data_section(const psiconv_buffer buf,int lev,
62 psiconv_paint_data_section *result) 62 psiconv_paint_data_section *result)
63{ 63{
64 int res = 0; 64 int res = 0;
65 int len = 0; 65 int len = 0;
66 int read_err = 0; 66 int read_err = 0;
67 psiconv_u32 size,offset,picsize,temp,datasize,pixelnr,datanr; 67 psiconv_u32 size,offset,picsize,temp,datasize,pixelnr,datanr,linelen;
68 psiconv_u8 marker; 68 psiconv_u8 marker;
69 int i; 69 int i;
70 70
71 psiconv_progress(lev+1,off,"Going to read a paint data section"); 71 psiconv_progress(lev+1,off,"Going to read a paint data section");
72 (*result) = malloc(sizeof(**result)); 72 (*result) = malloc(sizeof(**result));
76 psiconv_debug(lev+2,off+len,"Section size: %08x",size); 76 psiconv_debug(lev+2,off+len,"Section size: %08x",size);
77 len += 4; 77 len += 4;
78 78
79 psiconv_progress(lev+2,off+len,"Going to read pixel data offset"); 79 psiconv_progress(lev+2,off+len,"Going to read pixel data offset");
80 offset = psiconv_read_u32(buf,lev+2,off+len); 80 offset = psiconv_read_u32(buf,lev+2,off+len);
81 if (size != 0x28) { 81 if (offset != 0x28) {
82 psiconv_warn(lev+2,off+len, 82 psiconv_warn(lev+2,off+len,
83 "Paint data section data offset has unexpected value"); 83 "Paint data section data offset has unexpected value");
84 psiconv_debug(lev+2,off+len, 84 psiconv_debug(lev+2,off+len,
85 "Data offset: read %08x, expected %08x",offset,0x28); 85 "Data offset: read %08x, expected %08x",offset,0x28);
86 res = -1; 86 res = -1;
95 psiconv_progress(lev+2,off+len,"Going to read picture Y size"); 95 psiconv_progress(lev+2,off+len,"Going to read picture Y size");
96 (*result)->ysize = psiconv_read_u32(buf,lev+2,off+len); 96 (*result)->ysize = psiconv_read_u32(buf,lev+2,off+len);
97 psiconv_debug(lev+2,off+len,"Picture Y size: %08x:",(*result)->ysize); 97 psiconv_debug(lev+2,off+len,"Picture Y size: %08x:",(*result)->ysize);
98 len += 4; 98 len += 4;
99 99
100 picsize = (*result)->ysize * (*result)->xsize; 100 picsize = (*result)->ysize * (*result)->xsize * 2;
101 linelen = (*result)->xsize;
101 102
102 psiconv_progress(lev+2,off+len,"Going to read 6 unused longs"); 103 psiconv_progress(lev+2,off+len,"Going to read 6 unused longs");
103 for (i = 0 ; i < 6; i++) { 104 for (i = 0 ; i < 6; i++) {
104 temp = psiconv_read_u32(buf,lev+2,off+len); 105 temp = psiconv_read_u32(buf,lev+2,off+len);
105 if (temp != 0x00) { 106 if (temp != 0x00) {
171 datanr,marker); 172 datanr,marker);
172 res = -1; 173 res = -1;
173 read_err = 1; 174 read_err = 1;
174 } else { 175 } else {
175 temp = psiconv_read_u8(buf,lev+3,off+len+datanr); 176 temp = psiconv_read_u8(buf,lev+3,off+len+datanr);
176 for (i = 0; i < marker; i++) { 177 for (i = 0; i < marker; i++) {
177 (*result)->red[pixelnr + i*4] = 178 (*result)->red[pixelnr + i*4] =
178 (*result)->green[pixelnr + i*4] = 179 (*result)->green[pixelnr + i*4] =
179 (*result)->blue[pixelnr + i*4] = 180 (*result)->blue[pixelnr + i*4] =
180 (temp & 0x03) * (1.0/3.0); 181 (temp & 0x03) * (1.0/3.0);
181 (*result)->red[pixelnr + i*4 + 1] = 182 (*result)->red[pixelnr + i*4 + 1] =
208 209
209 if (length) 210 if (length)
210 *length = len; 211 *length = len;
211 212
212 psiconv_progress(lev+1,off+len-1,"End of paint data section " 213 psiconv_progress(lev+1,off+len-1,"End of paint data section "
213 "(total length: %08x", len); 214 "(total length: %08x)", len);
214 215
215 return res; 216 return res;
216} 217}
217 218
218 219

Legend:
Removed from v.12  
changed lines
  Added in v.13

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