From: kramm Date: Mon, 20 May 2002 14:24:10 +0000 (+0000) Subject: implemented filter bytes. X-Git-Tag: release-0-3-0-preview~7 X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=commitdiff_plain;h=1204eaea945b78ca2a8c8b8941365610881f69cf implemented filter bytes. --- diff --git a/src/png2swf.c b/src/png2swf.c index 52a442f..0e584e3 100644 --- a/src/png2swf.c +++ b/src/png2swf.c @@ -147,7 +147,19 @@ int png_read_header(FILE*fi, struct png_header*header) c = data[10]; // compression mode (0) f = data[11]; // filter mode (0) i = data[12]; // interlace mode (0) - printf("%08xx%08x %d %d %d %d %d\n",header->width, header->height, a,b,c,f,i); + if(c!=0) { + fprintf(stderr, "Compression mode %d not supported!\n", c); + exit(1); + } + if(f!=0) { + fprintf(stderr, "Filter mode %d not supported!\n", f); + exit(1); + } + if(i!=0) { + fprintf(stderr, "Interlace mode %d not supported!\n", i); + exit(1); + } + printf("%dx%d %d %d %d %d %d\n",header->width, header->height, a,b,c,f,i); header->bpp = a; header->mode = b; return 1; @@ -159,6 +171,102 @@ int png_read_header(FILE*fi, struct png_header*header) return 0; } +typedef unsigned char byte; +#define ABS(a) ((a)>0?(a):(-(a))) +byte inline PaethPredictor (byte a,byte b,byte c) +{ + // a = left, b = above, c = upper left + int p = a + b - c; // initial estimate + int pa = ABS(p - a); // distances to a, b, c + int pb = ABS(p - b); + int pc = ABS(p - c); + // return nearest of a,b,c, + // breaking ties in order a,b,c. + if (pa <= pb && pa <= pc) + return a; + else if (pb <= pc) + return b; + else return c; +} + +void applyfilter(int mode, U8*src, U8*old, U8*dest, int width) +{ + int x; + unsigned char lastr=0; + unsigned char lastg=0; + unsigned char lastb=0; + unsigned char upperlastr=0; + unsigned char upperlastg=0; + unsigned char upperlastb=0; + + if(mode==0) { + for(x=0;x32 bit conversion */ for(y=0;y