X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fpng2swf.c;h=d3247d8d263090954a67fd5a0c44b3336c1e9805;hb=f03de7ce28ee2c39fdb9f658359359429135c862;hp=47369398a122f4b69e7670b63ae74089ac883b26;hpb=287d3c4c457dcbe7b7dc1ddc3a63cc80cd390e71;p=swftools.git diff --git a/src/png2swf.c b/src/png2swf.c index 4736939..d3247d8 100644 --- a/src/png2swf.c +++ b/src/png2swf.c @@ -42,7 +42,7 @@ TAG *MovieStart(SWF * swf, int framerate, int dx, int dy) memset(swf, 0x00, sizeof(SWF)); - swf->fileVersion = 4; + swf->fileVersion = 5; swf->frameRate = (25600 / framerate); swf->movieSize.xmax = dx * 20; swf->movieSize.ymax = dy * 20; @@ -50,6 +50,7 @@ TAG *MovieStart(SWF * swf, int framerate, int dx, int dy) t = swf->firstTag = swf_InsertTag(NULL, ST_SETBACKGROUNDCOLOR); rgb.r = rgb.g = rgb.b = rgb.a = 0x00; + //rgb.g = 0xff; <--- handy for testing alpha conversion swf_SetRGB(t, &rgb); return t; @@ -65,7 +66,7 @@ int MovieFinish(SWF * swf, TAG * t, char *sname) else { if (!sname) sname = "output.swf"; - handle = open(sname, O_RDWR | O_CREAT | O_TRUNC, 0666); + handle = open(sname, O_BINARY | O_RDWR | O_CREAT | O_TRUNC, 0666); } if FAILED (swf_WriteSWF(handle, swf)) if (VERBOSE(1)) @@ -149,11 +150,11 @@ int png_read_header(FILE*fi, struct png_header*header) f = data[11]; // filter mode (0) i = data[12]; // interlace mode (0) - if(b!=2 && b!=3) { + if(b!=2 && b!=3 && b!=6) { fprintf(stderr, "Image mode %d not supported!\n", b); exit(1); } - if(a!=8 && b==2) { + if(a!=8 && (b==2 || b==6)) { fprintf(stderr, "Bpp %d in mode %d not supported!\n", a); exit(1); } @@ -199,7 +200,7 @@ byte inline PaethPredictor (byte a,byte b,byte c) else return c; } -void applyfilter(int mode, U8*src, U8*old, U8*dest, int width) +void applyfilter3(int mode, U8*src, U8*old, U8*dest, int width) { int x; unsigned char lastr=0; @@ -277,6 +278,89 @@ void applyfilter(int mode, U8*src, U8*old, U8*dest, int width) } +void applyfilter4(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 lasta=0; + unsigned char upperlastr=0; + unsigned char upperlastg=0; + unsigned char upperlastb=0; + unsigned char upperlasta=0; + + if(mode==0) { + for(x=0;x32 bit conversion */ + int opaque=0; + int transparent=0; + /* in case for mode 2, the following also performs 24->32 bit conversion */ for(y=0;yid = ST_DEFINEBITSJPEG3; + } + else +#endif + { + swf_SetLosslessBits(t, header.width, header.height, data2, BMF_32BIT); } - swf_SetLosslessBits(t, header.width, header.height, data2, BMF_32BIT); free(data2); } else { @@ -522,7 +643,7 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id) free(data2); } - t = swf_InsertTag(t, ST_DEFINESHAPE); + t = swf_InsertTag(t, ST_DEFINESHAPE3); swf_ShapeNew(&s); swf_GetMatrix(NULL, &m); @@ -548,14 +669,14 @@ TAG *MovieAddFrame(SWF * swf, TAG * t, char *sname, int id) swf_ShapeSetEnd(t); t = swf_InsertTag(t, ST_REMOVEOBJECT2); - swf_SetU16(t, 1); // depth + swf_SetU16(t, 50); // depth t = swf_InsertTag(t, ST_PLACEOBJECT2); swf_GetMatrix(NULL, &m); m.tx = (swf->movieSize.xmax - (int) header.width * 20) / 2; m.ty = (swf->movieSize.ymax - (int) header.height * 20) / 2; - swf_ObjectPlace(t, id + 1, 1, &m, NULL, NULL); + swf_ObjectPlace(t, id + 1, 50, &m, NULL, NULL); t = swf_InsertTag(t, ST_SHOWFRAME);