… | |
… | |
264 | << (greenbits+bluebits)) + |
264 | << (greenbits+bluebits)) + |
265 | (((psiconv_u32) (p_green * (1 << greenbits) + 0.5)) |
265 | (((psiconv_u32) (p_green * (1 << greenbits) + 0.5)) |
266 | << bluebits) + |
266 | << bluebits) + |
267 | ((psiconv_u32) (p_blue * (1 << bluebits) + 0.5)); |
267 | ((psiconv_u32) (p_blue * (1 << bluebits) + 0.5)); |
268 | else |
268 | else |
269 | pixel = (p_red + p_green + p_blue)/3.0 * (1 << colordepth); |
269 | pixel = (0.212671 * p_red + 0.715160 * p_green + 0.072169 * p_blue) * ((1 << colordepth) * 0.999); |
270 | } else { |
270 | } else { |
271 | dist = 4; /* Max distance is 3, so this is safe */ |
271 | dist = 4; /* Max distance is 3, so this is safe */ |
272 | pixel = -1; |
272 | pixel = -1; |
273 | for (i = 0; i < palet.length; i++) { |
273 | for (i = 0; i < palet.length; i++) { |
274 | new_dist = (p_red - palet.red[i]) * (p_red - palet.red[i]) + |
274 | new_dist = (p_red - palet.red[i]) * (p_red - palet.red[i]) + |
… | |
… | |
332 | outputbyte = 0; |
332 | outputbyte = 0; |
333 | for (y = 0; y < ysize; y++) { |
333 | for (y = 0; y < ysize; y++) { |
334 | outputbytenr = 0; |
334 | outputbytenr = 0; |
335 | for (x = 0; x < xsize; x++) { |
335 | for (x = 0; x < xsize; x++) { |
336 | if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) { |
336 | if (!(pixelptr = psiconv_list_get(pixels,y*xsize+x))) { |
337 | psiconv_error(config,lev,0,"Massive internal corruption"); |
337 | psiconv_error(config,lev,0,"Data structure corruption"); |
338 | res = -PSICONV_E_NOMEM; |
338 | res = -PSICONV_E_NOMEM; |
339 | goto ERROR2; |
339 | goto ERROR2; |
340 | } |
340 | } |
341 | inputbitsleft = colordepth; |
341 | inputbitsleft = colordepth; |
342 | inputdata = *pixelptr; |
342 | inputdata = *pixelptr; |
… | |
… | |
958 | psiconv_error(config,lev,0,"Writing of jumptable section failed"); |
958 | psiconv_error(config,lev,0,"Writing of jumptable section failed"); |
959 | else |
959 | else |
960 | psiconv_progress(config,lev,0,"End of jumptable section"); |
960 | psiconv_progress(config,lev,0,"End of jumptable section"); |
961 | return res; |
961 | return res; |
962 | } |
962 | } |
963 | |
|
|