import { ColorTransform, Matrix, Rectangle, Point, IAssetAdapter } from '@awayjs/core'; import { UnloadManager, IUnloadable } from './../managers/UnloadManager'; import { Image2D } from './Image2D'; interface LazyImageSymbolTag { needParse: boolean; lazyParser(): LazyImageSymbolTag; definition: { width: number; height: number; data: Uint8ClampedArray; isPMA?: boolean; }; } export declare class BitmapImage2D extends Image2D implements IUnloadable { static UNLOAD_EVENT: string; static assetType: string; static _unloadManager: UnloadManager; static getManager(stage: Stage): UnloadManager; private _asyncRead; _lazySymbol: LazyImageSymbolTag; protected _isSymbolSource: boolean; protected _data: Uint8ClampedArray; protected _isWeakRef: boolean; protected _finalizer: FinalizationRegistry; protected _weakRefAdapter: WeakRef; protected _transparent: boolean; protected _unpackPMA: boolean; protected _stage: Stage; protected _locked: boolean; protected _floodStack: number[]; protected _imageDataDirty: boolean; protected _initalFillColor: number; protected _lastUsedFill: number; protected syncData(async?: boolean): boolean | Promise; getDataInternal(constructEmpty?: boolean, skipSync?: boolean): Uint8ClampedArray; needUpload: boolean; /** * @description Upload flag, marking a image that it was uploaded on GPU * and can use GPU operations * fillRect can be implemented on GPU or CPU */ wasUpload: boolean; invalidateGPU(): void; invalidate(): void; isUnloaded: boolean; lastUsedTime: number; get canUnload(): boolean; unmarkToUnload(): void; markToUnload(): void; unload(): void; private _customMipLevels; addMipLevel(newLevel: BitmapImage2D): void; get mipLevels(): BitmapImage2D[]; /** * * @returns {string} */ get assetType(): string; /** * 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. */ get transparent(): boolean; set transparent(value: boolean); /** * Store a mode, witch should be uploaded to GPU * not all case PMA is should be enabled */ get unpackPMA(): boolean; /** * 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.

* * @param width The width of the bitmap image in pixels. * @param height The height of the bitmap image in pixels. * @param transparent 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. * @param fillColor A 32-bit ARGB color value that you use to fill the * bitmap image area. The default value is * 0xFFFFFFFF(solid white). */ constructor(width: number, height: number, transparent?: boolean, fillColor?: number, powerOfTwo?: boolean, stage?: Stage); addLazySymbol(tag: LazyImageSymbolTag): void; applySymbol(): boolean; /** * @description transfer adapter to weak mode * Reference will dropped, and adapter destroyed after collecting a adapter */ useWeakRef(): void; unuseWeakRef(): void; get isWeakRef(): boolean; set adapter(v: IAssetAdapter); get adapter(): IAssetAdapter; private onAdapterDropped; copyTo(target: BitmapImage2D): void; /** * Returns a new BitmapImage2D object that is a clone of the original instance * with an exact copy of the contained bitmap. * * @return A new BitmapImage2D object that is identical to the original. */ clone(): BitmapImage2D; /** * 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. * * @param rect A Rectangle object that defines the area of the * image in which the ColorTransform object is applied. * @param colorTransform A ColorTransform object that describes the color * transformation values to apply. */ colorTransform(rect: Rectangle, colorTransform: ColorTransform): 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
  • *
* * @param sourceBitmapImage2D The input bitmap image to use. The source image * can be a different BitmapImage2D object or it can * refer to the current BitmapImage2D object. * @param sourceRect 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. * @param destPoint 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). * @param sourceChannel The source channel. Use a value from the * BitmapImage2DChannel class * (BitmapImage2DChannel.RED, * BitmapImage2DChannel.BLUE, * BitmapImage2DChannel.GREEN, * BitmapImage2DChannel.ALPHA). * @param destChannel The destination channel. Use a value from the * BitmapImage2DChannel class * (BitmapImage2DChannel.RED, * BitmapImage2DChannel.BLUE, * BitmapImage2DChannel.GREEN, * BitmapImage2DChannel.ALPHA). * @throws TypeError The sourceBitmapImage2D, sourceRect or destPoint are null. */ copyChannel(sourceBitmap: BitmapImage2D, sourceRect: Rectangle, destPoint: Point, sourceChannel: number, destChannel: number): void; merge(source: BitmapImage2D, sourceRect: Rectangle, destPoint: Point, redMultiplier: number, greenMultiplier: number, blueMultiplier: number, alphaMultiplier: number): 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.

* */ dispose(): void; getColorBoundsRect(mask: number, color: number, findColor?: boolean): Rectangle; hitTest(firstPoint: Point, firstAlphaThreshold: ui8, secondObject: Point | Rectangle | BitmapImage2D, secondBitmapDataPoint?: Point, secondAlphaThreshold?: ui8): boolean; floodFill(x: number, y: number, color: number): void; /** * Ruffle port of noise * @see https://github.com/ruffle-rs/ruffle/blob/d43b033caa98ed201f37558c25f9ce5f2da189d0/core/src/avm1/object/bitmap_data.rs#L326 */ noise(randomSeed: number, low?: ui8, high?: ui8, channelOptions?: ui8, grayScale?: boolean): void; /** * Ruffle port of perlinNoise * There are not guarantees that it valid =) * RESULT IS NOT EQUAL A FLASH RESULT, SEED IS WRONG!! * @see https://github.com/ruffle-rs/ruffle/blob/d43b033caa98ed201f37558c25f9ce5f2da189d0/core/src/avm1/object/bitmap_data.rs#L713 */ perlinNoise(baseX: number, baseY: number, numOctaves: number, randomSeed: number, stitch: boolean, fractalNoise: boolean, channelOptions?: ui8, grayScale?: boolean, offsets?: Array): void; drawBitmap(source: Uint8ClampedArray, offsetX: number, offsetY: number, width: number, height: number, matrix?: Matrix): void; /** * Fills a rectangular area of pixels with a specified ARGB color. * * @param rect The rectangular area to fill. * @param color The ARGB color value that fills the area. ARGB colors are * often specified in hexadecimal format; for example, * 0xFF336699. * @throws TypeError The rect is null. */ fillRect(rect: Rectangle, color: number, useCPU?: boolean): void; /** * 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.

* * @param x The x position of the pixel. * @param y The y position of the pixel. * @return A number that represents an RGB pixel value. If the(x, * y) coordinates are outside the bounds of the image, the * method returns 0. */ getPixel(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.

* * @param x The x position of the pixel. * @param y The y position of the pixel. * @return A number representing an ARGB pixel value. If the(x, * y) coordinates are outside the bounds of the image, 0 is * returned. */ getPixel32(x: any, y: any): number; /** * Returns unmultiplied ARGB bytes for a rectangular region: * packed as [A,R,G,B, A,R,G,B, ...] (same channel order as getPixel32 / ByteArray). * Always returns a copy - never aliases internal RGBA storage. */ getPixels(rect: Rectangle): Uint8ClampedArray; /** * Raw storage RGBA for one pixel (PMA when !_unpackPMA). Internal use - * public unmultiplied ARGB reads should use getPixel32 / getPixels. */ getPixelData(x: any, y: any, imagePixel: Uint8ClampedArray): void; setPixelData(x: any, y: any, imagePixel: Uint8ClampedArray): 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. * */ lock(): 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. * * @param rect Specifies the rectangular region of the BitmapImage2D * object. * @param inputArray An Array that consists of 32-bit unmultiplied pixel * values to be used in the rectangular region. * @throws RangeError The vector array is not large enough to read all the * pixel data. */ setArray(rect: Rectangle, inputArray: Array): 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.

* * @param x The x position of the pixel whose value changes. * @param y The y position of the pixel whose value changes. * @param color The resulting RGB color for the pixel. */ setPixel(x: number, y: number, color: number): void; setPixelFromArray(x: number, y: number, colors: 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.

* * @param x The x position of the pixel whose value changes. * @param y The y position of the pixel whose value changes. * @param color The resulting ARGB color for the pixel. If the bitmap is * opaque(not transparent), the alpha transparency portion of * this color value is ignored. */ setPixel32(x: number, y: number, color: number): 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. * * @param rect Specifies the rectangular region of the BitmapImage2D * object. * @param input A ByteArray object that consists of 32-bit * unmultiplied pixel values to be used in the * rectangular region. * @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. */ setPixels(rect: Rectangle, input: Uint8ClampedArray): void; applyFilter(source: BitmapImage2D, sourceRect: Rectangle, destPoint: Point, filter: any): boolean; /** * 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. * * @param changeRect The area of the BitmapImage2D object that has changed. If * you do not specify a value for this parameter, the * entire area of the BitmapImage2D object is considered * changed. */ unlock(): void; /** * @inheritdoc */ set alphaChannel(buff: Uint8Array); /** * * @returns {ImageData} */ get data(): Uint8ClampedArray; /** * * @param width * @param height * @private */ _setSize(width: number, height: number): void; private getDebugCanvas; private getDebugImage; } import { ITextureBase } from '../base/ITextureBase'; import { _Stage_Image2D } from './Image2D'; import { Stage } from '../Stage'; /** * * @class away.pool.ImageObjectBase */ export declare class _Stage_BitmapImage2D extends _Stage_Image2D { private onUnload; init(image: BitmapImage2D, pool: Stage): void; onClear(): void; getTexture(): ITextureBase; } export {}; //# sourceMappingURL=BitmapImage2D.d.ts.map