Skip to content

Commit 450d548

Browse files
committed
Updated README
1 parent 951fbe8 commit 450d548

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

README.mdown

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,30 @@ encoder.addEventListener(Event.COMPLETE, function (e) {
7878
// want to be notified of progress
7979
```
8080

81+
### Bonus: PNG decoding
82+
83+
Update: Support for synchronous decoding of PNGs that were created using PNGEncoder2 has been added:
84+
85+
```as3
86+
var bmp : BitmapData = ...;
87+
var png : ByteArray = PNGEncoder2.encode(bmp);
88+
bmp = PNGEncoder2.decode(png); // Round-trip back to BitmapData
89+
```
90+
91+
Decoding is about twice as fast as encoding, though it should be stressed that only PNGEncoder2 PNGs
92+
can be decoded properly, not arbitrary PNGs. The advantage is that decoding is faster than using the
93+
built-in flash.display.Loader object, at the cost of reduced flexibility; if you need to decode arbitrary
94+
PNG files, or you want to decode asynchronously, use the Loader as usual:
95+
96+
```as3
97+
var png : ByteArray = ...; // From a file or encoded PNG ByteArray
98+
var loader : Loader = new Loader();
99+
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function (e) {
100+
var bmp : BitmapData = new BitmapData((int)loader.width, (int)loader.height, true, 0x00FFFFFF);
101+
bmp.draw(loader); // Write the decoded PNG to a bitmap data object
102+
});
103+
loader.loadBytes(png);
104+
```
81105

82106
Installation
83107
============
@@ -124,7 +148,10 @@ All you need are the
124148
If you want to have only one compression method compiled
125149
(to cut down on generated code size), add `-D FAST_ONLY`,
126150
`-D NORMAL_ONLY`, or `-D GOOD_ONLY` to your compile options
127-
(this is equivalent to using the slim SWC versions).
151+
(this is equivalent to using the slim SWC versions). The
152+
`decode` method is by default not compiled in; to enable it,
153+
add the `-D DECODER` compile option (which can be combined with
154+
the others above).
128155

129156

130157
[blog]: http://moodycamel.com/blog/2011/a-better-png-encoder-for-flash

0 commit comments

Comments
 (0)