Packagemx.graphics.codec
Classpublic class JPEGEncoder
InheritanceJPEGEncoder Inheritance Object
Implements IImageEncoder

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

The JPEGEncoder class converts raw bitmap images into encoded images using Joint Photographic Experts Group (JPEG) compression. For information about the JPEG algorithm, see the document http://www.opennet.ru/docs/formats/jpeg.txt by Cristi Cuturicu.



Public Properties
 PropertyDefined By
  contentType : String
[read-only] The MIME type for the JPEG encoded image.
JPEGEncoder
Public Methods
 MethodDefined By
  
JPEGEncoder(quality:Number = 50.0)
Constructor.
JPEGEncoder
  
encode(bitmapData:BitmapData):ByteArray
Converts the pixels of BitmapData object to a JPEG-encoded ByteArray object.
JPEGEncoder
  
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 JPEG-encoded ByteArray object.
JPEGEncoder
Property Detail
contentTypeproperty
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 JPEG encoded image. The value is "image/jpeg".


Implementation
    public function get contentType():String
Constructor Detail
JPEGEncoder()Constructor
public function JPEGEncoder(quality:Number = 50.0)

Language Version : ActionScript 3.0
Product Version : Flex 3
Runtime Versions : Flash Player 9, AIR 1.1

Constructor.

Parameters
quality:Number (default = 50.0) — A value between 0.0 and 100.0. The smaller the quality value, the smaller the file size of the resultant image. The value does not affect the encoding speed. Note that even though this value is a number between 0.0 and 100.0, it does not represent a percentage. The default value is 50.0.
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 BitmapData object to a JPEG-encoded ByteArray object.

Parameters

bitmapData:BitmapData — The input BitmapData object.

Returns
ByteArray — Returns a ByteArray object containing JPEG-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 JPEG-encoded ByteArray object. The original ByteArray is left unchanged. Transparency is not supported; however you still must represent each pixel as four bytes in ARGB format.

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.

Returns
ByteArray — Returns a ByteArray object containing JPEG-encoded image data.