Skip to content

PNGEncoder

Nick Ryzhy edited this page Apr 4, 2016 · 11 revisions

Encodes image data using PNG compression algorithm. This class may use different compression techniques provided in PNG8Encoder and PNG24Encoder.

Name Value
Package by.blooddy.crypto.image
Name class PNGEncoder
Inheritance PNGEncoderProcessEventDispatcherObject
Subclasses PNG24Encoder, PNG8Encoder

Examples

Sync
import by.blooddy.crypto.PNGEncoder;
var result:ByteArray = PNGEncoder.encode( bytes, 100, 100, PNGFilter.NONE );
Async
import by.blooddy.crypto.PNGEncoder;
import by.blooddy.crypto.PNGFilter;
import by.blooddy.crypto.events.ProcessEvent;

var png:PNGEncoder = new PNGEncoder();
png.encode( bytes, 100, 100, PNGFilter.NONE );
png.addEventListener( ProcessEvent.COMPLETE, function(event:ProcessEvent):void {
	var result:ByteArray = event.data;
	trace( result ); // async result
} );
png.addEventListener( ProcessEvent.ERROR, function(event:ProcessEvent):void {
	var error:Error = event.data;
	trace( error ); // async error
} );

Static Methods

Name Description
encode(image:BitmapData, filter:uint=0):ByteArray Creates a PNG-encoded byte sequence from the specified BitmapData. Used BitmapData.encode(), if posible.
encodeBytes(bytes:ByteArray, width:uint, height:uint, filter:uint=0):ByteArray Creates a PNG-encoded byte sequence from the specified ByteArray.

Constructor

Name Description
PNGEncoder() Creates a PNGEncoder object.

Methods

Name Description
encode(image:BitmapData, filter:uint=0):ByteArray Asynchronously creates a PNG-encoded byte sequence from the specified BitmapData. Dispatched sequence of bytes in ProcessEvent.
encodeBytes(bytes:ByteArray, width:uint, height:uint, filter:uint=0):ByteArray Asynchronously creates a PNG-encoded byte sequence from the specified ByteArray. Dispatched sequence of bytes in ProcessEvent.

Events

Name Type Description
complete ProcessEvent Dispatched when success.
error ProcessEvent Dispatched when fault.

Hashsum

Checksum

Image

Serialization

Clone this wiki locally