git.asbjorn.biz
/
swftools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added mode 2 transparency support
[swftools.git]
/
lib
/
png.c
diff --git
a/lib/png.c
b/lib/png.c
index
f517151
..
49c3c3d
100644
(file)
--- a/
lib/png.c
+++ b/
lib/png.c
@@
-545,8
+545,9
@@
int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata)
}
printf("\n");*/
}
}
printf("\n");*/
}
- if(data)
- free(data);
+ if(data) {
+ free(data); data=0;
+ }
}
if(!zimagedata || uncompress(imagedata, &imagedatalen, zimagedata, zimagedatalen) != Z_OK) {
}
if(!zimagedata || uncompress(imagedata, &imagedatalen, zimagedata, zimagedatalen) != Z_OK) {
@@
-602,6
+603,7
@@
int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata)
}
}
free(old);
}
}
free(old);
+ free(imagedata);
} else if(header.mode == 6 || header.mode == 2) {
int i,s=0;
int x,y;
} else if(header.mode == 6 || header.mode == 2) {
int i,s=0;
int x,y;
@@
-632,11
+634,24
@@
int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata)
} else {
old = &data2[(y-1)*header.width*4];
}
} else {
old = &data2[(y-1)*header.width*4];
}
- if(header.mode == 6)
+ if(header.mode == 6) {
applyfilter4(mode, src, old, dest, header.width);
applyfilter4(mode, src, old, dest, header.width);
- else // header.mode = 2
+ } else { // header.mode = 2
applyfilter3(mode, src, old, dest, header.width);
applyfilter3(mode, src, old, dest, header.width);
+ /* replace alpha color */
+ if(hasalphacolor) {
+ int x;
+ for(x=0;x<header.width;x++) {
+ if(dest[x*4+1] == alphacolor[0] &&
+ dest[x*4+2] == alphacolor[1] &&
+ dest[x*4+3] == alphacolor[2]) {
+ *(U32*)&dest[x*4] = 0;
+ }
+ }
+ }
+ }
}
}
+ free(imagedata);
} else if(header.mode == 0 || header.mode == 3) {
COL*rgba = 0;
U8*tmpline = (U8*)malloc(header.width+1);
} else if(header.mode == 0 || header.mode == 3) {
COL*rgba = 0;
U8*tmpline = (U8*)malloc(header.width+1);
@@
-726,6
+741,7
@@
int getPNG(char*sname, int*destwidth, int*destheight, unsigned char**destdata)
free(tmpline);
free(destline);
free(rgba);
free(tmpline);
free(destline);
free(rgba);
+ free(imagedata);
} else {
printf("expected PNG mode to be 2, 3 or 6 (is:%d)\n", header.mode);
return 0;
} else {
printf("expected PNG mode to be 2, 3 or 6 (is:%d)\n", header.mode);
return 0;