--- psiconv/trunk/lib/psiconv/parse_image.c 1999/10/30 22:28:54 25 +++ psiconv/trunk/lib/psiconv/parse_image.c 1999/12/04 20:53:11 45 @@ -23,16 +23,16 @@ #include "data.h" #include "parse_routines.h" -int psiconv_parse_mbm_jumptable_section(const psiconv_buffer buf,int lev, - psiconv_u32 off, int *length, - psiconv_mbm_jumptable_section *result) +int psiconv_parse_jumptable_section(const psiconv_buffer buf,int lev, + psiconv_u32 off, int *length, + psiconv_jumptable_section *result) { int res = 0; int len = 0; psiconv_u32 listlen,temp; int i; - psiconv_progress(lev+1,off+len,"Going to read the mbm jumptable section"); + psiconv_progress(lev+1,off+len,"Going to read the jumptable section"); (*result) = psiconv_list_new(sizeof(psiconv_u32)); psiconv_progress(lev+2,off+len,"Going to read the list length"); @@ -51,7 +51,7 @@ if (length) *length = len; - psiconv_progress(lev+1,off+len-1,"End of mbm jumptable section " + psiconv_progress(lev+1,off+len-1,"End of jumptable section " "(total length: %08x)", len); return res; @@ -92,7 +92,7 @@ int psiconv_parse_paint_data_section(const psiconv_buffer buf,int lev, - psiconv_u32 off, int *length, + psiconv_u32 off, int *length,int isclipart, psiconv_paint_data_section *result) { int res = 0; @@ -178,12 +178,38 @@ compression = 1; } psiconv_debug(lev+2,off+len,"Compression: %s",compression?"RLE":"none"); + len += 4; + + if (isclipart) { + psiconv_progress(lev+2,off+len,"Going to read an unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0xffffffff) { + psiconv_warn(lev+2,off+len, + "Paint data section prologue has unknown values"); + psiconv_debug(lev+2,off+len, + "offset %02x: read %08x, expected %08x",i,temp, 0xffffffff); + res = -1; + } + len += 4; + psiconv_progress(lev+2,off+len,"Going to read a second unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0x44) { + psiconv_warn(lev+2,off+len, + "Paint data section prologue has unknown values"); + psiconv_debug(lev+2,off+len, + "offset %02x: read %08x, expected %08x",i,temp, 0x44); + res = -1; + } + len += 4; + } (*result)->red = malloc(sizeof(float) * picsize); (*result)->green = malloc(sizeof(float) * picsize); (*result)->blue = malloc(sizeof(float) * picsize); len = offset; datasize = size - len; + if (isclipart) + len += 8; psiconv_progress(lev+2,off+len,"Going to read the pixel data"); pixelnr = 0; @@ -395,7 +421,7 @@ } psiconv_progress(lev+2,off+len,"Going to read the picture data"); - res |= psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng, + res |= psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,0, &((*result)->picture)); off += leng; if (!is_object) { @@ -448,3 +474,87 @@ return res; } + +int psiconv_parse_clipart_section(const psiconv_buffer buf,int lev, + psiconv_u32 off, int *length, + psiconv_clipart_section *result) +{ + int res=0; + int len=0; + int leng; + psiconv_u32 temp; + + psiconv_progress(lev+1,off+len,"Going to read the clipart section"); + *result = malloc(sizeof(**result)); + + psiconv_progress(lev+2,off+len,"Going to read the section ID"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != PSICONV_ID_CLIPART_ITEM) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, + PSICONV_ID_CLIPART_ITEM); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Clipart ID: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read an unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0x02) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, + 0x02); + res = -1; + } else + psiconv_debug(lev+2,off+len,"First unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a second unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Second unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a third unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if (temp != 0) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x",temp, 0); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Third unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read a fourth unknown long"); + temp = psiconv_read_u32(buf,lev+2,off+len); + if ((temp != 0x0c) && (temp != 0x08)) { + psiconv_warn(lev+2,off+len, + "Unexpected value in clipart section preamble"); + psiconv_debug(lev+2,off+len,"Read %08x, expected %08x or %08x",temp, + 0x0c, 0x08); + res = -1; + } else + psiconv_debug(lev+2,off+len,"Fourth unknown long: %08x", temp); + off += 4; + + psiconv_progress(lev+2,off+len,"Going to read the Paint Data Section"); + res |= psiconv_parse_paint_data_section(buf,lev+2,off+len,&leng,1, + &((*result)->picture)); + len += leng; + + if (length) + *length = len; + + psiconv_progress(lev,off+len-1, + "End of clipart section (total length: %08x)", len); + + return res; +}