swftools
swftools copied to clipboard
zlib stream original size exactly calculation in lossless tag.
- dissmiss incremental malloc & uncompress try loop.
- calculating accurate datalen value from lossless tag info.
- fixing to (signed) int overflow & sign flip problem with 32-bit environment.
- https://github.com/matthiaskramm/swftools/pull/71
- etc
- check malloc return value.
- fix to memory leak with corrupted zlib stream.
- delete unused variables (tmp, tmp32, ...), code comment.
TEST1 (format5, without alpha, large size)
% convert -size 7083x9744 xc:gray png24:gray-7083x9744.png
% png2swf gray-7083x9744.png
% swfextract output.swf
Objects in file output.swf:
[-i] 1 Shape: ID(s) 2
[-p] 1 PNG: ID(s) 1
[-f] 1 Frame: ID(s) 0
% swfextract -v output.swf -p 1
VERBOSE Width 7083
VERBOSE Height 9744
VERBOSE Format 5
VERBOSE Cols 0
VERBOSE Bpp 32
VERBOSE Alpha 0
VERBOSE Uncompressed image is 276067008 bytes (0 colormap)
VERBOSE Compressed data is 224917 bytes
% identify output.png
output.png PNG 7083x9744 7083x9744+0+0 8-bit sRGB 224974B 0.000u 0:00.000
TEST2 (format5, with alpha, odd size)
% convert rose: -crop 69x45+0+0 -fuzz 30% -transparent black rose-69x45-alpha.png
% png2swf rose-69x45-alpha.png
% swfextract output.swf -p 1 -v
VERBOSE Width 69
VERBOSE Height 45
VERBOSE Format 5
VERBOSE Cols 0
VERBOSE Bpp 32
VERBOSE Alpha 1
VERBOSE Uncompressed image is 12420 bytes (0 colormap)
VERBOSE Compressed data is 7495 bytes
% identify output.png
output.png PNG 69x45 69x45+0+0 8-bit sRGB 7552B 0.000u 0:00.000
TEST3 (format3, with pading)
% convert rose: -crop 69x45+0+0 png8:rose-69x45.png
% png2swf rose-69x45.png -o rose-69x45.swf
% swfextract -v rose-69x45.swf
Objects in file rose-69x45.swf:
[-i] 1 Shape: ID(s) 2
[-p] 1 PNG: ID(s) 1
[-f] 1 Frame: ID(s) 0
% swfextract -v rose-69x45.swf -p 1
VERBOSE Width 69
VERBOSE Height 45
VERBOSE Format 3
VERBOSE Cols 113
VERBOSE Bpp 8
VERBOSE Alpha 0
VERBOSE Uncompressed image is 3579 bytes (339 colormap)
VERBOSE Compressed data is 1524 bytes
% identify output.png
output.png PNG 69x45 69x45+0+0 8-bit sRGB 256c 2361B 0.000u 0:00.000