Options
Menu

Class BitmapImageCube

The BitmapImage2D export class lets you work with the data(pixels) of a Bitmap object. You can use the methods of the BitmapImage2D export class to create arbitrarily sized transparent or opaque bitmap images and manipulate them in various ways at runtime. You can also access the BitmapImage2D for a bitmap image that you load with the flash.Assets or flash.display.Loader classes.

This export class lets you separate bitmap rendering operations from the internal display updating routines of flash. By manipulating a BitmapImage2D object directly, you can create complex images without incurring the per-frame overhead of constantly redrawing the content from vector data.

The methods of the BitmapImage2D export class support effects that are not available through the filters available to non-bitmap display objects.

A BitmapImage2D object contains an array of pixel data. This data can represent either a fully opaque bitmap or a transparent bitmap that contains alpha channel data. Either type of BitmapImage2D object is stored as a buffer of 32-bit integers. Each 32-bit integer determines the properties of a single pixel in the bitmap.

Each 32-bit integer is a combination of four 8-bit channel values(from 0 to 255) that describe the alpha transparency and the red, green, and blue (ARGB) values of the pixel.(For ARGB values, the most significant byte represents the alpha channel value, followed by red, green, and blue.)

The four channels(alpha, red, green, and blue) are represented as numbers when you use them with the BitmapImage2D.copyChannel() method or the DisplacementMapFilter.componentX and DisplacementMapFilter.componentY properties, and these numbers are represented by the following constants in the BitmapImage2DChannel class:

  • BitmapImage2DChannel.ALPHA
  • BitmapImage2DChannel.RED
  • BitmapImage2DChannel.GREEN
  • BitmapImage2DChannel.BLUE

You can attach BitmapImage2D objects to a Bitmap object by using the bitmapData property of the Bitmap object.

You can use a BitmapImage2D object to fill a Graphics object by using the Graphics.beginBitmapFill() method.

You can also use a BitmapImage2D object to perform batch tile rendering using the flash.display.Tilesheet class.

In Flash Player 10, the maximum size for a BitmapImage2D object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels.(So, if a BitmapImage2D object is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier, the limitation is 2,880 pixels in height and 2,880 in width.

Hierarchy

Implements

  • IAsset
  • IAssetAdapter

Index

Constructors

constructor

  • new BitmapImageCube(size: number, transparent?: boolean, fillColor?: number): BitmapImageCube
  • Creates a BitmapImage2D object with a specified width and height. If you specify a value for the fillColor parameter, every pixel in the bitmap is set to that color.

    By default, the bitmap is created as transparent, unless you pass the value false for the transparent parameter. After you create an opaque bitmap, you cannot change it to a transparent bitmap. Every pixel in an opaque bitmap uses only 24 bits of color channel information. If you define the bitmap as transparent, every pixel uses 32 bits of color channel information, including an alpha transparency channel.

    Parameters

    • size: number
    • Default value transparent: boolean = true

      Specifies whether the bitmap image supports per-pixel transparency. The default value is true (transparent). To create a fully transparent bitmap, set the value of the transparent parameter to true and the value of the fillColor parameter to 0x00000000(or to 0). Setting the transparent property to false can result in minor improvements in rendering performance.

    • Default value fillColor: number = null

      A 32-bit ARGB color value that you use to fill the bitmap image area. The default value is 0xFFFFFFFF(solid white).

    Returns BitmapImageCube

Properties

_adapter

_adapter: IAssetAdapter

_pFormat

_pFormat: string

_size

_size: number

adaptee

adaptee: AssetBase

adapter

adapter: IAssetAdapter

adapter is used to provide MovieClip to scripts taken from different platforms setter typically managed by factory. getter defaults to AwayJS class

assetFullPath

assetFullPath: Array<string>

assetNamespace

assetNamespace: string

id

id: number

A unique id for the asset, used to identify assets in an associative array

name

name: string

originalName

originalName: string

The original name used for this asset in the resource (e.g. file) in which it was found. This may not be the same as name, which may have changed due to of a name conflict.

Static DEFAULT_NAMESPACE

DEFAULT_NAMESPACE: string

Static ID_COUNT

ID_COUNT: number

Static assetType

assetType: string

Static negX

negX: number

Static negY

negY: number

Static negZ

negZ: number

Static posX

posX: number

Static posY

posY: number

Static posZ

posZ: number

Accessors

assetType

  • get (): string

format

  • get (): string
  • Returns string

size

  • get (): number
  • set (value: number): void
  • The size of the cube bitmap in pixels.

    Returns number

  • The size of the cube bitmap in pixels.

    Parameters

    • value: number

    Returns void

transparent

  • get (): boolean
  • set (value: boolean): void
  • Defines whether the bitmap image supports per-pixel transparency. You can set this value only when you construct a BitmapImage2D object by passing in true for the transparent parameter of the constructor. Then, after you create a BitmapImage2D object, you can check whether it supports per-pixel transparency by determining if the value of the transparent property is true.

    Returns boolean

  • Defines whether the bitmap image supports per-pixel transparency. You can set this value only when you construct a BitmapImage2D object by passing in true for the transparent parameter of the constructor. Then, after you create a BitmapImage2D object, you can check whether it supports per-pixel transparency by determining if the value of the transparent property is true.

    Parameters

    • value: boolean

    Returns void

Methods

Private _setSize

  • _setSize(size: number): void
  • Parameters

    • size: number

    Returns void

addEventListener

  • addEventListener(type: string, listener: function): void
  • Add an event listener

    method

    addEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

assetPathEquals

  • assetPathEquals(name: string, ns: string): boolean
  • Parameters

    • name: string
    • ns: string

    Returns boolean

clear

  • clear(): void
  • Returns void

clone

  • Returns a new BitmapImage2D object that is a clone of the original instance with an exact copy of the contained bitmap.

    Returns BitmapImageCube

    A new BitmapImage2D object that is identical to the original.

colorTransform

  • colorTransform(side: number, rect: Rectangle, colorTransform: ColorTransform): void
  • Adjusts the color values in a specified area of a bitmap image by using a ColorTransform object. If the rectangle matches the boundaries of the bitmap image, this method transforms the color values of the entire image.

    Parameters

    • side: number
    • rect: Rectangle

      A Rectangle object that defines the area of the image in which the ColorTransform object is applied.

    • colorTransform: ColorTransform

      A ColorTransform object that describes the color transformation values to apply.

    Returns void

copyChannel

  • copyChannel(side: number, sourceBitmap: BitmapImage2D, sourceRect: Rectangle, destPoint: Point, sourceChannel: number, destChannel: number): void
  • Transfers data from one channel of another BitmapImage2D object or the current BitmapImage2D object into a channel of the current BitmapImage2D object. All of the data in the other channels in the destination BitmapImage2D object are preserved.

    The source channel value and destination channel value can be one of following values:

    • BitmapImage2DChannel.RED
    • BitmapImage2DChannel.GREEN
    • BitmapImage2DChannel.BLUE
    • BitmapImage2DChannel.ALPHA
    throws

    TypeError The sourceBitmapImage2D, sourceRect or destPoint are null.

    Parameters

    • side: number
    • sourceBitmap: BitmapImage2D
    • sourceRect: Rectangle

      The source Rectangle object. To copy only channel data from a smaller area within the bitmap, specify a source rectangle that is smaller than the overall size of the BitmapImage2D object.

    • destPoint: Point

      The destination Point object that represents the upper-left corner of the rectangular area where the new channel data is placed. To copy only channel data from one area to a different area in the destination image, specify a point other than (0,0).

    • sourceChannel: number

      The source channel. Use a value from the BitmapImage2DChannel class (BitmapImage2DChannel.RED, BitmapImage2DChannel.BLUE, BitmapImage2DChannel.GREEN, BitmapImage2DChannel.ALPHA).

    • destChannel: number

      The destination channel. Use a value from the BitmapImage2DChannel class (BitmapImage2DChannel.RED, BitmapImage2DChannel.BLUE, BitmapImage2DChannel.GREEN, BitmapImage2DChannel.ALPHA).

    Returns void

copyPixels

  • copyPixels(side: number, source: BitmapImage2D, sourceRect: Rectangle, destPoint: Point): any
  • copyPixels(side: number, source: HTMLImageElement, sourceRect: Rectangle, destPoint: Point): any
  • Provides a fast routine to perform pixel manipulation between images with no stretching, rotation, or color effects. This method copies a rectangular area of a source image to a rectangular area of the same size at the destination point of the destination BitmapImage2D object.

    If you include the alphaBitmap and alphaPoint parameters, you can use a secondary image as an alpha source for the source image. If the source image has alpha data, both sets of alpha data are used to composite pixels from the source image to the destination image. The alphaPoint parameter is the point in the alpha image that corresponds to the upper-left corner of the source rectangle. Any pixels outside the intersection of the source image and alpha image are not copied to the destination image.

    The mergeAlpha property controls whether or not the alpha channel is used when a transparent image is copied onto another transparent image. To copy pixels with the alpha channel data, set the mergeAlpha property to true. By default, the mergeAlpha property is false.

    throws

    TypeError The sourceBitmapImage2D, sourceRect, destPoint are null.

    Parameters

    • side: number
    • source: BitmapImage2D
    • sourceRect: Rectangle

      A rectangle that defines the area of the source image to use as input.

    • destPoint: Point

      The destination point that represents the upper-left corner of the rectangular area where the new pixels are placed.

    Returns any

  • Parameters

    • side: number
    • source: HTMLImageElement
    • sourceRect: Rectangle
    • destPoint: Point

    Returns any

dispatchEvent

  • dispatchEvent(event: EventBase): void
  • Dispatch an event

    method

    dispatchEvent

    Parameters

    • event: EventBase

    Returns void

dispose

  • dispose(): void
  • Frees memory that is used to store the BitmapImage2D object.

    When the dispose() method is called on an image, the width and height of the image are set to 0. All subsequent calls to methods or properties of this BitmapImage2D instance fail, and an exception is thrown.

    BitmapImage2D.dispose() releases the memory occupied by the actual bitmap data, immediately(a bitmap can consume up to 64 MB of memory). After using BitmapImage2D.dispose(), the BitmapImage2D object is no longer usable and an exception may be thrown if you call functions on the BitmapImage2D object. However, BitmapImage2D.dispose() does not garbage collect the BitmapImage2D object(approximately 128 bytes); the memory occupied by the actual BitmapImage2D object is released at the time the BitmapImage2D object is collected by the garbage collector.

    Returns void

draw

  • draw(side: number, source: BitmapImage2D, matrix?: Matrix, colorTransform?: ColorTransform, blendMode?: BlendMode, clipRect?: Rectangle, smoothing?: boolean): any
  • draw(side: number, source: HTMLElement, matrix?: Matrix, colorTransform?: ColorTransform, blendMode?: BlendMode, clipRect?: Rectangle, smoothing?: boolean): any
  • Draws the source display object onto the bitmap image, using the NME software renderer. You can specify matrix, colorTransform, blendMode, and a destination clipRect parameter to control how the rendering performs. Optionally, you can specify whether the bitmap should be smoothed when scaled(this works only if the source object is a BitmapImage2D object).

    The source display object does not use any of its applied transformations for this call. It is treated as it exists in the library or file, with no matrix transform, no color transform, and no blend mode. To draw a display object(such as a movie clip) by using its own transform properties, you can copy its transform property object to the transform property of the Bitmap object that uses the BitmapImage2D object.

    throws

    ArgumentError The source parameter is not a BitmapImage2D or DisplayObject object.

    throws

    ArgumentError The source is null or not a valid IBitmapDrawable object.

    throws

    SecurityError The source object and(in the case of a Sprite or MovieClip object) all of its child objects do not come from the same domain as the caller, or are not in a content that is accessible to the caller by having called the Security.allowDomain() method. This restriction does not apply to AIR content in the application security sandbox.

    Parameters

    • side: number
    • source: BitmapImage2D

      The display object or BitmapImage2D object to draw to the BitmapImage2D object.(The DisplayObject and BitmapImage2D classes implement the IBitmapDrawable interface.)

    • Optional matrix: Matrix

      A Matrix object used to scale, rotate, or translate the coordinates of the bitmap. If you do not want to apply a matrix transformation to the image, set this parameter to an identity matrix, created with the default new Matrix() constructor, or pass a null value.

    • Optional colorTransform: ColorTransform

      A ColorTransform object that you use to adjust the color values of the bitmap. If no object is supplied, the bitmap image's colors are not transformed. If you must pass this parameter but you do not want to transform the image, set this parameter to a ColorTransform object created with the default new ColorTransform() constructor.

    • Optional blendMode: BlendMode

      A string value, from the flash.display.BlendMode class, specifying the blend mode to be applied to the resulting bitmap.

    • Optional clipRect: Rectangle

      A Rectangle object that defines the area of the source object to draw. If you do not supply this value, no clipping occurs and the entire source object is drawn.

    • Optional smoothing: boolean

      A Boolean value that determines whether a BitmapImage2D object is smoothed when scaled or rotated, due to a scaling or rotation in the matrix parameter. The smoothing parameter only applies if the source parameter is a BitmapImage2D object. With smoothing set to false, the rotated or scaled BitmapImage2D image can appear pixelated or jagged. For example, the following two images use the same BitmapImage2D object for the source parameter, but the smoothing parameter is set to true on the left and false on the right:

                        <p>Drawing a bitmap with <code>smoothing</code> set
                        to <code>true</code> takes longer than doing so with
                        <code>smoothing</code> set to
                        <code>false</code>.</p>
      

    Returns any

  • Parameters

    • side: number
    • source: HTMLElement
    • Optional matrix: Matrix
    • Optional colorTransform: ColorTransform
    • Optional blendMode: BlendMode
    • Optional clipRect: Rectangle
    • Optional smoothing: boolean

    Returns any

fillRect

  • fillRect(side: number, rect: Rectangle, color: number): void
  • Fills a rectangular area of pixels with a specified ARGB color.

    throws

    TypeError The rect is null.

    Parameters

    • side: number
    • rect: Rectangle

      The rectangular area to fill.

    • color: number

      The ARGB color value that fills the area. ARGB colors are often specified in hexadecimal format; for example, 0xFF336699.

    Returns void

getCanvas

  • getCanvas(side: number): HTMLCanvasElement
  • Parameters

    • side: number

    Returns HTMLCanvasElement

getImageData

  • getImageData(side: number): ImageData
  • Parameters

    • side: number

    Returns ImageData

getPixel

  • getPixel(side: number, x: number, y: number): number
  • Returns an integer that represents an RGB pixel value from a BitmapImage2D object at a specific point(x, y). The getPixel() method returns an unmultiplied pixel value. No alpha information is returned.

    All pixels in a BitmapImage2D object are stored as premultiplied color values. A premultiplied image pixel has the red, green, and blue color channel values already multiplied by the alpha data. For example, if the alpha value is 0, the values for the RGB channels are also 0, independent of their unmultiplied values. This loss of data can cause some problems when you perform operations. All BitmapImage2D methods take and return unmultiplied values. The internal pixel representation is converted from premultiplied to unmultiplied before it is returned as a value. During a set operation, the pixel value is premultiplied before the raw image pixel is set.

    Parameters

    • side: number
    • x: number

      The x position of the pixel.

    • y: number

      The y position of the pixel.

    Returns number

    A number that represents an RGB pixel value. If the(x, y) coordinates are outside the bounds of the image, the method returns 0.

getPixel32

  • getPixel32(side: number, x: any, y: any): number
  • Returns an ARGB color value that contains alpha channel data and RGB data. This method is similar to the getPixel() method, which returns an RGB color without alpha channel data.

    All pixels in a BitmapImage2D object are stored as premultiplied color values. A premultiplied image pixel has the red, green, and blue color channel values already multiplied by the alpha data. For example, if the alpha value is 0, the values for the RGB channels are also 0, independent of their unmultiplied values. This loss of data can cause some problems when you perform operations. All BitmapImage2D methods take and return unmultiplied values. The internal pixel representation is converted from premultiplied to unmultiplied before it is returned as a value. During a set operation, the pixel value is premultiplied before the raw image pixel is set.

    Parameters

    • side: number
    • x: any

      The x position of the pixel.

    • y: any

      The y position of the pixel.

    Returns number

    A number representing an ARGB pixel value. If the(x, y) coordinates are outside the bounds of the image, 0 is returned.

hasEventListener

  • hasEventListener(type: string, listener?: function): boolean
  • check if an object has an event listener assigned to it

    method

    hasListener

    Parameters

    • type: string
    • Optional listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns boolean

invalidate

  • invalidate(): void
  • Returns void

invalidateMipmaps

  • invalidateMipmaps(): void

isAsset

  • isAsset(assetClass: IAssetClass): boolean
  • Parameters

    • assetClass: IAssetClass

    Returns boolean

lock

  • lock(): void
  • Locks an image so that any objects that reference the BitmapImage2D object, such as Bitmap objects, are not updated when this BitmapImage2D object changes. To improve performance, use this method along with the unlock() method before and after numerous calls to the setPixel() or setPixel32() method.

    Returns void

removeEventListener

  • removeEventListener(type: string, listener: function): void
  • Remove an event listener

    method

    removeEventListener

    Parameters

    • type: string
    • listener: function
        • (event: EventBase): void
        • Parameters

          • event: EventBase

          Returns void

    Returns void

resetAssetPath

  • resetAssetPath(name: string, ns?: string, overrideOriginal?: boolean): void
  • Parameters

    • name: string
    • Optional ns: string
    • Optional overrideOriginal: boolean

    Returns void

setArray

  • setArray(side: number, rect: Rectangle, inputArray: Array<number>): void
  • Converts an Array into a rectangular region of pixel data. For each pixel, an Array element is read and written into the BitmapImage2D pixel. The data in the Array is expected to be 32-bit ARGB pixel values.

    throws

    RangeError The vector array is not large enough to read all the pixel data.

    Parameters

    • side: number
    • rect: Rectangle

      Specifies the rectangular region of the BitmapImage2D object.

    • inputArray: Array<number>

      An Array that consists of 32-bit unmultiplied pixel values to be used in the rectangular region.

    Returns void

setPixel

  • setPixel(side: number, x: number, y: number, color: number): void
  • Sets a single pixel of a BitmapImage2D object. The current alpha channel value of the image pixel is preserved during this operation. The value of the RGB color parameter is treated as an unmultiplied color value.

    Note: To increase performance, when you use the setPixel() or setPixel32() method repeatedly, call the lock() method before you call the setPixel() or setPixel32() method, and then call the unlock() method when you have made all pixel changes. This process prevents objects that reference this BitmapImage2D instance from updating until you finish making the pixel changes.

    Parameters

    • side: number
    • x: number

      The x position of the pixel whose value changes.

    • y: number

      The y position of the pixel whose value changes.

    • color: number

      The resulting RGB color for the pixel.

    Returns void

setPixel32

  • setPixel32(side: number, x: any, y: any, color: number): void
  • Sets the color and alpha transparency values of a single pixel of a BitmapImage2D object. This method is similar to the setPixel() method; the main difference is that the setPixel32() method takes an ARGB color value that contains alpha channel information.

    All pixels in a BitmapImage2D object are stored as premultiplied color values. A premultiplied image pixel has the red, green, and blue color channel values already multiplied by the alpha data. For example, if the alpha value is 0, the values for the RGB channels are also 0, independent of their unmultiplied values. This loss of data can cause some problems when you perform operations. All BitmapImage2D methods take and return unmultiplied values. The internal pixel representation is converted from premultiplied to unmultiplied before it is returned as a value. During a set operation, the pixel value is premultiplied before the raw image pixel is set.

    Note: To increase performance, when you use the setPixel() or setPixel32() method repeatedly, call the lock() method before you call the setPixel() or setPixel32() method, and then call the unlock() method when you have made all pixel changes. This process prevents objects that reference this BitmapImage2D instance from updating until you finish making the pixel changes.

    Parameters

    • side: number
    • x: any

      The x position of the pixel whose value changes.

    • y: any

      The y position of the pixel whose value changes.

    • color: number

      The resulting ARGB color for the pixel. If the bitmap is opaque(not transparent), the alpha transparency portion of this color value is ignored.

    Returns void

setPixels

  • setPixels(side: number, rect: Rectangle, inputByteArray: ByteArray): void
  • Converts a byte array into a rectangular region of pixel data. For each pixel, the ByteArray.readUnsignedInt() method is called and the return value is written into the pixel. If the byte array ends before the full rectangle is written, the function returns. The data in the byte array is expected to be 32-bit ARGB pixel values. No seeking is performed on the byte array before or after the pixels are read.

    throws

    EOFError The inputByteArray object does not include enough data to fill the area of the rect rectangle. The method fills as many pixels as possible before throwing the exception.

    throws

    TypeError The rect or inputByteArray are null.

    Parameters

    • side: number
    • rect: Rectangle

      Specifies the rectangular region of the BitmapImage2D object.

    • inputByteArray: ByteArray

      A ByteArray object that consists of 32-bit unmultiplied pixel values to be used in the rectangular region.

    Returns void

unlock

  • unlock(): void
  • Unlocks an image so that any objects that reference the BitmapImage2D object, such as Bitmap objects, are updated when this BitmapImage2D object changes. To improve performance, use this method along with the lock() method before and after numerous calls to the setPixel() or setPixel32() method.

    Returns void

updateFullPath

  • updateFullPath(): void
  • Returns void

Generated using TypeDoc