X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fmodules%2Fswfbits.c;h=1e32cf2ec7e17c5929b80a2dde9e43bdb976d654;hp=4643551695a7c0348d8e1c75ba1e19bcf1f6f900;hb=006f7afc9efc533175af7eba679998af948adfa3;hpb=6c8f037f0f76ce4b28b80a2133e4150d93012ef7 diff --git a/lib/modules/swfbits.c b/lib/modules/swfbits.c index 4643551..1e32cf2 100644 --- a/lib/modules/swfbits.c +++ b/lib/modules/swfbits.c @@ -61,30 +61,6 @@ int swf_ImageHasAlpha(RGBA*img, int width, int height) return hasalpha; } -int swf_ImageGetNumberOfPaletteEntries2(RGBA*_img, int width, int height) -{ - int len = width*height; - int t; - U32* img = (U32*)_img; - U32 color1 = img[0]; - U32 color2 = 0; - for(t=1;tnewwidth?width:newwidth)*2*sizeof(scale_lookup_t)); - scale_lookup_t**lblockx = (scale_lookup_t**)malloc((newwidth+1)*sizeof(scale_lookup_t**)); - double fx = ((double)width)/((double)newwidth); - double px = 0; - int x; - scale_lookup_t*p_x = lookupx; - - if(newwidth<=width) { - for(x=0;x=width) tox = width-1; - for(xx=fromx;xx<=tox;xx++) { - if(xx==fromx && xx==tox) p_x->weight = 256; - else if(xx==fromx) p_x->weight = xweight; - else if(xx==tox) p_x->weight = 256-w; - else p_x->weight = i; - w+=p_x->weight; - p_x->pos = xx; - p_x++; - } - px = ex; - } - } else { - for(x=0;x=width) ix2=width-1; - lblockx[x] = p_x; - if(bicubic) - r = -2*r*r*r+3*r*r; - p_x[0].weight = (int)(256*(1-r)); - p_x[0].pos = ix1; - p_x[1].weight = 256-p_x[0].weight; - p_x[1].pos = ix2; - p_x+=2; - px += fx; - } - } - lblockx[newwidth] = p_x; - return lblockx; -} - -static void encodeMonochromeImage(RGBA*data, int width, int height, RGBA*colors) -{ - int t; - int len = width*height; - - U32* img = (U32*)data; - U32 color1 = img[0]; - U32 color2 = 0; - for(t=1;t> 8; - data[t].g = (colors[0].g * (255-m) + colors[1].g * m) >> 8; - data[t].b = (colors[0].b * (255-m) + colors[1].b * m) >> 8; - data[t].a = (colors[0].a * (255-m) + colors[1].a * m) >> 8; - } -} - -static void blurImage(RGBA*src, int width, int height, int r) -{ - int e = 2; // r times e is the sampling interval - double*gauss = (double*)malloc(r*e*sizeof(double)); - double sum=0; - int x; - for(x=0;x> 16; - d[x].g = g >> 16; - d[x].b = b >> 16; - d[x].a = a >> 16; - } - for(x=width-range;x> 16; - d[yy].g = g >> 16; - d[yy].b = b >> 16; - d[yy].a = a >> 16; - yy += width; - } - for(y=0;y4) { - /* high-resolution monochrome images are usually dithered, so - low-pass filter them first to get rid of any moire patterns */ - blurImage(data, width, height, r+1); - } - } - - tmpline = (rgba_int_t*)malloc(width*sizeof(rgba_int_t)); - newdata = (RGBA*)malloc(newwidth*newheight*sizeof(RGBA)); - - lblockx = make_scale_lookup(width, newwidth); - lblocky = make_scale_lookup(height, newheight); - - for(p=lblocky[0];ppos*=width; - - for(y=0;ypos]; - scale_lookup_t*p_x; - int weight = p_y->weight; - for(x=0;xpos]; - unsigned int weight = p_x->weight; - r += col->r*weight; - g += col->g*weight; - b += col->b*weight; - a += col->a*weight; - p_x++; - } while (p_xr = r >> 16; - destline->g = g >> 16; - destline->b = b >> 16; - destline->a = a >> 16; - - destline++; - } - } - - if(monochrome) - decodeMonochromeImage(newdata, newwidth, newheight, monochrome_colors); - - free(tmpline); - free(*lblockx); - free(lblockx); - free(*lblocky); - free(lblocky); - return newdata; -} - -