--- psiconv/trunk/lib/psiconv/parse_image.c 2003/11/21 15:39:14 162 +++ psiconv/trunk/lib/psiconv/parse_image.c 2003/11/22 22:17:04 163 @@ -389,139 +389,99 @@ } int psiconv_parse_sketch_section(const psiconv_buffer buf, int lev, - psiconv_u32 off, int *length, int is_object, + psiconv_u32 off, int *length, psiconv_sketch_section *result) { int res=0; int len=0; psiconv_u32 temp; int leng; - int i; psiconv_progress(lev+1,off,"Going to read the sketch section"); if (!(*result = malloc(sizeof(**result)))) goto ERROR1; - if (!is_object) { - psiconv_progress(lev+2,off+len,"Going to read the form hor. size"); - (*result)->form_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Form hor. size: %04x", - (*result)->form_xsize); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the form ver. size"); - (*result)->form_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Form ver. size: %04x", - (*result)->form_ysize); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the picture hor. offset"); - (*result)->picture_x_offset = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Picture hor. offset: %04x", - (*result)->picture_x_offset); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the picture ver. offset"); - (*result)->picture_y_offset = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Picture ver. offset: %04x", - (*result)->picture_y_offset); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to skip 5 words of zeros"); - for (i = 0; i < 5; i++) { - temp = psiconv_read_u16(buf,lev+2,off+len,&res); - if (res) - goto ERROR2; - if (temp != 0) { - psiconv_warn(lev+2,off+len, - "Unexpected value in sketch section preamble (ignored)"); - psiconv_debug(lev+2,off+len,"Word %d: Read %04x, expected %04x",i, - temp,0); - } - off += 0x02; - } - } else { - psiconv_progress(lev+2,off+len,"Going to read the displayed hor. size"); - (*result)->picture_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Displayed hor. size: %04x", - (*result)->picture_xsize); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the displayed ver. size"); - (*result)->picture_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Displayed ver. size: %04x", - (*result)->picture_ysize); - len += 0x02; - - psiconv_progress(lev+2,off+len,"Going to skip 2 words of zeros"); - for (i = 0; i < 2; i++) { - temp = psiconv_read_u16(buf,lev+2,off+len,&res); - if (res) - goto ERROR2; - if (temp != 0) { - psiconv_warn(lev+2,off+len, - "Unexpected value in sketch section preamble (ignored)"); - psiconv_debug(lev+2,off+len,"Word %d: Read %04x, expected %04x",i, - temp,0); - } - off += 0x02; - } - psiconv_progress(lev+2,off+len,"Going to read the picture hor. offset"); - (*result)->picture_x_offset = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Picture hor. offset: %04x", - (*result)->picture_x_offset); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the picture ver. offset"); - (*result)->picture_y_offset = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Picture ver. offset: %04x", - (*result)->picture_y_offset); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the form hor. size"); - (*result)->form_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Form hor. size: %04x", - (*result)->form_xsize); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to read the form ver. size"); - (*result)->form_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); - if (res) - goto ERROR2; - psiconv_debug(lev+2,off+len,"Form ver. size: %04x", - (*result)->form_ysize); - len += 0x02; - psiconv_progress(lev+2,off+len,"Going to skip 1 zero word"); - temp = psiconv_read_u16(buf,lev+2,off+len,&res); - if (res) - goto ERROR2; - if (temp != 0) { - psiconv_warn(lev+2,off+len, - "Unexpected value in sketch section preamble (ignored)"); - psiconv_debug(lev+2,off+len,"Read %04x, expected %04x",i, temp,0); - } - off += 0x02; + psiconv_progress(lev+2,off+len,"Going to read the displayed hor. size"); + (*result)->displayed_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Displayed hor. size: %04x", + (*result)->displayed_xsize); + len += 0x02; + psiconv_progress(lev+2,off+len,"Going to read displayed ver. size"); + (*result)->displayed_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Displayed ver. size: %04x", + (*result)->displayed_ysize); + len += 0x02; + + psiconv_progress(lev+2,off+len,"Going to read the data hor. offset"); + (*result)->picture_data_x_offset = psiconv_read_u16(buf,lev+2,off + len, + &res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Data hor. offset: %04x", + (*result)->picture_data_x_offset); + len += 0x02; + psiconv_progress(lev+2,off+len,"Going to read the data ver. offset"); + (*result)->picture_data_y_offset = psiconv_read_u16(buf,lev+2,off + len, + &res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Data ver. offset: %04x", + (*result)->picture_data_y_offset); + len += 0x02; + + psiconv_progress(lev+2,off+len,"Going to read the displayed hor. offset"); + (*result)->displayed_size_x_offset = psiconv_read_u16(buf,lev+2,off + len, + &res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Displayed hor. offset: %04x", + (*result)->displayed_size_x_offset); + len += 0x02; + psiconv_progress(lev+2,off+len,"Going to read the displayed ver. offset"); + (*result)->displayed_size_y_offset = psiconv_read_u16(buf,lev+2,off + len, + &res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Displayed ver. offset: %04x", + (*result)->displayed_size_y_offset); + len += 0x02; + + psiconv_progress(lev+2,off+len,"Going to read the form hor. size"); + (*result)->form_xsize = psiconv_read_u16(buf,lev+2,off + len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Form hor. size: %04x", + (*result)->form_xsize); + len += 0x02; + psiconv_progress(lev+2,off+len,"Going to read form ver. size"); + (*result)->form_ysize = psiconv_read_u16(buf,lev+2,off + len,&res); + if (res) + goto ERROR2; + psiconv_debug(lev+2,off+len,"Form ver. size: %04x", + (*result)->form_ysize); + len += 0x02; + + psiconv_progress(lev+2,off+len,"Going to skip 1 word of zeros"); + temp = psiconv_read_u16(buf,lev+2,off+len,&res); + if (res) + goto ERROR2; + if (temp != 0) { + psiconv_warn(lev+2,off+len, + "Unexpected value in sketch section preamble (ignored)"); + psiconv_debug(lev+2,off+len,"Read %04x, expected %04x", + temp,0); } + off += 0x02; psiconv_progress(lev+2,off+len,"Going to read the picture data"); if ((res = psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,0, &((*result)->picture)))) goto ERROR2; off += leng; - if (!is_object) { - (*result)->picture_xsize = (*result)->picture->xsize; - (*result)->picture_ysize = (*result)->picture->ysize; - } psiconv_progress(lev+2,off+len,"Going to read the hor. magnification"); (*result)->magnification_x = psiconv_read_u16(buf,lev+2,off+len,&res)/1000.0; @@ -542,7 +502,7 @@ temp = psiconv_read_u32(buf,lev+2,off + len,&res); if (res) goto ERROR3; - (*result)->cut_left = (temp * 6.0) / (*result)->picture_xsize; + (*result)->cut_left = (temp * 6.0) / (*result)->displayed_xsize; psiconv_debug(lev+2,off+len,"Left cut: raw %08x, real: %f", temp,(*result)->cut_left); len += 0x04; @@ -550,7 +510,7 @@ temp = psiconv_read_u32(buf,lev+2,off + len,&res); if (res) goto ERROR3; - (*result)->cut_right = (temp * 6.0) / (*result)->picture_xsize; + (*result)->cut_right = (temp * 6.0) / (*result)->displayed_xsize; psiconv_debug(lev+2,off+len,"Right cut: raw %08x, real: %f", temp,(*result)->cut_right); len += 0x04; @@ -558,7 +518,7 @@ temp = psiconv_read_u32(buf,lev+2,off + len,&res); if (res) goto ERROR3; - (*result)->cut_top = (temp * 6.0) / (*result)->picture_ysize; + (*result)->cut_top = (temp * 6.0) / (*result)->displayed_ysize; psiconv_debug(lev+2,off+len,"Top cut: raw %08x, real: %f", temp,(*result)->cut_top); len += 0x04; @@ -566,7 +526,7 @@ temp = psiconv_read_u32(buf,lev+2,off + len,&res); if (res) goto ERROR3; - (*result)->cut_bottom = (temp * 6.0) / (*result)->picture_ysize; + (*result)->cut_bottom = (temp * 6.0) / (*result)->displayed_ysize; psiconv_debug(lev+2,off+len,"Bottom cut: raw %08x, real: %f", temp,(*result)->cut_bottom); len += 0x04;