--- psiconv/trunk/lib/psiconv/generate_image.c 2004/02/25 20:56:43 230 +++ psiconv/trunk/lib/psiconv/generate_image.c 2004/02/25 20:57:10 231 @@ -36,7 +36,7 @@ int colordepth,int color, int redbits,int greenbits,int bluebits, const psiconv_pixel_floats_t palet); -static int psiconv_pixel_data_to_bytes(const psiconv_config config, +static int psiconv_pixel_data_to_bytes(const psiconv_config config,int lev, psiconv_pixel_bytes *bytes, int xsize, int ysize, const psiconv_pixel_ints pixels, int colordepth); @@ -71,7 +71,7 @@ if ((config->colordepth != 2) && (config->colordepth != 4) && (config->colordepth != 8) && (config->colordepth != 12) && (config->colordepth != 16) && (config->colordepth != 24)) { - psiconv_error(config,0,psiconv_buffer_length(buf), + psiconv_error(config,lev,0, "Unsupported color depth (%d); try 2, 4, 8, 16 or 24", config->colordepth); res = -PSICONV_E_GENERATE; @@ -81,7 +81,7 @@ if ((config->color) && (config->bluebits || config->redbits || config->greenbits) && (config->bluebits+config->redbits+config->greenbits!=config->colordepth)) { - psiconv_error(config,0,psiconv_buffer_length(buf), + psiconv_error(config,lev,0, "Sum of red (%d), green (%d) and blue (%d) bits should be " "equal to the color depth (%d)", config->redbits,config->greenbits,config->bluebits, @@ -93,7 +93,7 @@ if (config->color && !(config->redbits || config->greenbits || config->bluebits) && (config->colordepth != 4) && (config->colordepth != 8)) { - psiconv_error(config,0,psiconv_buffer_length(buf), + psiconv_error(config,lev,0, "Current color depth (%d) has no palet associated with it", config->colordepth); res = -PSICONV_E_GENERATE; @@ -101,12 +101,12 @@ } if (config->color || (config->colordepth != 2)) - psiconv_warn(config,0,psiconv_buffer_length(buf), + psiconv_warn(config,lev,0, "All image types except 2-bit greyscale are experimental!"); if (!value) { - psiconv_error(config,0,psiconv_buffer_length(buf),"Null paint data section"); + psiconv_error(config,lev,0,"Null paint data section"); res = -PSICONV_E_GENERATE; goto ERROR1; } @@ -134,8 +134,9 @@ goto ERROR1; } - if ((res = psiconv_pixel_data_to_bytes(config,&bytes,value->xsize,value->ysize, - ints,config->colordepth))) { + if ((res = psiconv_pixel_data_to_bytes(config,lev+1,&bytes,value->xsize, + value->ysize,ints, + config->colordepth))) { psiconv_error(config,lev,0,"Error translating pixel data to bytes"); goto ERROR2; } @@ -225,6 +226,10 @@ ERROR2: psiconv_list_free(ints); ERROR1: + if (res) + psiconv_error(config,lev,0,"Writing of paint data section failed"); + else + psiconv_progress(config,lev,0,"End of paint data section"); return res; } @@ -287,7 +292,7 @@ return res; } -int psiconv_pixel_data_to_bytes(const psiconv_config config, +int psiconv_pixel_data_to_bytes(const psiconv_config config,int lev, psiconv_pixel_bytes *bytes, int xsize, int ysize, const psiconv_pixel_ints pixels, int colordepth) @@ -302,17 +307,17 @@ if (!bytes) { - psiconv_error(config,0,0,"NULL pixel data"); + psiconv_error(config,lev,0,"NULL pixel data"); res = -PSICONV_E_GENERATE; goto ERROR1; } if (!pixels) { - psiconv_error(config,0,0,"NULL pixel data"); + psiconv_error(config,lev,0,"NULL pixel data"); res = -PSICONV_E_GENERATE; goto ERROR1; } if (psiconv_list_length(pixels) != xsize * ysize) { - psiconv_error(config,0,0,"Pixel number is not correct"); + psiconv_error(config,lev,0,"Pixel number is not correct"); res = -PSICONV_E_GENERATE; goto ERROR1; } @@ -329,7 +334,7 @@ outputbytenr = 0; for (x = 0; x < xsize; x++) { if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) { - psiconv_error(config,0,0,"Massive internal corruption"); + psiconv_error(config,lev,0,"Massive internal corruption"); res = -PSICONV_E_NOMEM; goto ERROR2; } @@ -839,7 +844,7 @@ psiconv_progress(config,lev,0,"Writing sketch section"); if (!value) { - psiconv_error(config,0,0,"NULL sketch section"); + psiconv_error(config,lev,0,"NULL sketch section"); res = -PSICONV_E_GENERATE; goto ERROR1; } @@ -882,6 +887,10 @@ goto ERROR1; ERROR1: + if (res) + psiconv_error(config,lev,0,"Writing of sketch section failed"); + else + psiconv_progress(config,lev,0,"End of sketch section"); return res; } @@ -893,8 +902,7 @@ psiconv_progress(config,lev,0,"Writing clipart section"); if (!value) { - psiconv_error(config,0,psiconv_buffer_length(buf), - "NULL Clipart Section"); + psiconv_error(config,lev,0, "NULL Clipart Section"); res = -PSICONV_E_GENERATE; goto ERROR; } @@ -912,6 +920,10 @@ goto ERROR; ERROR: + if (res) + psiconv_error(config,lev,0,"Writing of clipart section failed"); + else + psiconv_progress(config,lev,0,"End of clipart section"); return res; } @@ -925,8 +937,7 @@ psiconv_progress(config,lev,0,"Writing jumptable section"); if (!value) { - psiconv_error(config,0,psiconv_buffer_length(buf), - "NULL Jumptable Section"); + psiconv_error(config,lev,0,"NULL Jumptable Section"); res = -PSICONV_E_GENERATE; goto ERROR; } @@ -934,8 +945,7 @@ goto ERROR; for (i = 0; i < psiconv_list_length(value); i++) { if (!(offset_ptr = psiconv_list_get(value,i))) { - psiconv_error(config,0,psiconv_buffer_length(buf), - "Massive memory corruption"); + psiconv_error(config,lev,0,"Massive memory corruption"); res = -PSICONV_E_NOMEM; goto ERROR; } @@ -944,6 +954,10 @@ } ERROR: + if (res) + psiconv_error(config,lev,0,"Writing of jumptable section failed"); + else + psiconv_progress(config,lev,0,"End of jumptable section"); return res; }