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;t<len;t++) {
+ if(img[t] != color1) {
+ color2 = img[t];
+ break;
+ }
+ }
+ if(t==len)
+ return 1;
+
+ for(;t<len;t++) {
+ if(img[t] != color1 && img[t] != color2) {
+ return width*height;
+ }
+ }
+ return 2;
+}
+
/*int swf_ImageGetNumberOfPaletteEntries(RGBA*img, int width, int height, RGBA*palette)
{
int len = width*height;
palette[t].b = data[pos++];
if (alpha) {
palette[t].a = data[pos++];
+ } else {
+ palette[t].a = 255;
}
}
}
}
} else {
for (x = 0; x < width; x++) {
- /* TODO: un-premultiply alpha? */
+ /* TODO: premultiply alpha?
+ dest[pos2].r = (data[pos + 1]*255)/data[pos+0];
+ dest[pos2].g = (data[pos + 2]*255)/data[pos+0];
+ dest[pos2].b = (data[pos + 3]*255)/data[pos+0];
+ */
dest[pos2].r = data[pos + 1];
dest[pos2].g = data[pos + 2];
dest[pos2].b = data[pos + 3];
lblockx[newwidth] = p_x;
return lblockx;
}
-
RGBA* swf_ImageScale(RGBA*data, int width, int height, int newwidth, int newheight)
{
int x,y;
if(newwidth<1 || newheight<1)
return 0;
+ /* this is bad because this scaler doesn't yet handle monochrome
+ images with 2 colors in a way that the final image hasn't more
+ than 256 colors */
+ if(swf_ImageGetNumberOfPaletteEntries2(data, width, height) == 2)
+ fprintf(stderr, "Warning: scaling monochrome image\n");
+
tmpline = (rgba_int_t*)malloc(width*sizeof(rgba_int_t));
newdata = (RGBA*)malloc(newwidth*newheight*sizeof(RGBA));