mx.graphics.codec

# PNGEncoder - AS3 Flex

Package | mx.graphics.codec
Class | public class PNGEncoder
Inheritance | PNGEncoder Object
Implements | IImageEncoder

Language Version: | ActionScript 3.0

Product Version: | Flex 3

Runtime Versions: | Flash Player 9, AIR 1.1

The PNGEncoder class converts raw bitmap images into encoded images using Portable Network Graphics (PNG) lossless compression.

For the PNG specification, see http://www.w3.org/TR/PNG/

.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | contentType : String [read-only] The MIME type for the PNG encoded image. | PNGEncoder

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | PNGEncoder() Constructor. | PNGEncoder
|  | encode(bitmapData:BitmapData):ByteArray Converts the pixels of a BitmapData object to a PNG-encoded ByteArray object. | PNGEncoder
|  | encodeByteArray(byteArray:ByteArray, width:int, height:int, transparent:Boolean = true):ByteArray Converts a ByteArray object containing raw pixels in 32-bit ARGB (Alpha, Red, Green, Blue) format to a new PNG-encoded ByteArray object. | PNGEncoder
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

### contentType

property

`contentType:String` [read-only]

Language Version: | ActionScript 3.0

Product Version: | Flex 3

Runtime Versions: | Flash Player 9, AIR 1.1

The MIME type for the PNG encoded image. The value is `"image/png"`.

Implementation
`public function get contentType():String`
Constructor Detail

### PNGEncoder

()
Constructor

`public function PNGEncoder()`

Language Version: | ActionScript 3.0

Product Version: | Flex 3

Runtime Versions: | Flash Player 9, AIR 1.1

Constructor.

Method Detail

### encode

()
method

`public function encode(bitmapData:BitmapData):ByteArray`

Language Version: | ActionScript 3.0

Product Version: | Flex 3

Runtime Versions: | Flash Player 9, AIR 1.1

Converts the pixels of a BitmapData object to a PNG-encoded ByteArray object.

Parameters

| `bitmapData:BitmapData` — The input BitmapData object.

Returns

| `ByteArray` — Returns a ByteArray object containing PNG-encoded image data.

### encodeByteArray

()
method

`public function encodeByteArray(byteArray:ByteArray, width:int, height:int, transparent:Boolean = true):ByteArray`

Language Version: | ActionScript 3.0

Product Version: | Flex 3

Runtime Versions: | Flash Player 9, AIR 1.1

Converts a ByteArray object containing raw pixels in 32-bit ARGB (Alpha, Red, Green, Blue) format to a new PNG-encoded ByteArray object. The original ByteArray is left unchanged.

Parameters

| `byteArray:ByteArray` — The input ByteArray object containing raw pixels. This ByteArray should contain `4 width height` bytes. Each pixel is represented by 4 bytes, in the order ARGB. The first four bytes represent the top-left pixel of the image. The next four bytes represent the pixel to its right, etc. Each row follows the previous one without any padding.
| `width:int` — The width of the input image, in pixels.
| `height:int` — The height of the input image, in pixels.
| `transparent:Boolean` (default = `true`)`` — If `false`, alpha channel information is ignored but you still must represent each pixel as four bytes in ARGB format.

Returns

| `ByteArray` — Returns a ByteArray object containing PNG-encoded image data.

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00