@pixi/core
Version:
Core PixiJS
75 lines (74 loc) • 2.66 kB
TypeScript
import { ALPHA_MODES } from '@pixi/constants';
import { BaseImageResource } from './BaseImageResource';
import type { Renderer } from '../../Renderer';
import type { BaseTexture } from '../BaseTexture';
import type { GLTexture } from '../GLTexture';
export interface IImageBitmapResourceOptions {
/** Start loading process automatically when constructed. */
autoLoad?: boolean;
/** Load image using cross origin. */
crossOrigin?: boolean;
/** Alpha mode used when creating the ImageBitmap. */
alphaMode?: ALPHA_MODES;
}
/**
* Resource type for ImageBitmap.
* @memberof PIXI
*/
export declare class ImageBitmapResource extends BaseImageResource {
/** URL of the image source. */
url: string | null;
/**
* Load image using cross origin.
* @default false
*/
crossOrigin: boolean;
/**
* Controls texture alphaMode field
* Copies from options
* Default is `null`, copies option from baseTexture
* @readonly
*/
alphaMode: ALPHA_MODES | null;
/**
* Promise when loading.
* @default null
*/
private _load;
/**
* @param source - ImageBitmap or URL to use
* @param options
* @param {boolean} [options.autoLoad=true] - Start loading process automatically when constructed.
* @param {boolean} [options.crossOrigin=true] - Load image using cross origin.
* @param {PIXI.ALPHA_MODES} [options.alphaMode=null] - Alpha mode used when creating the ImageBitmap.
*/
constructor(source: ImageBitmap | string, options?: IImageBitmapResourceOptions);
load(): Promise<ImageBitmapResource>;
/**
* Upload the image bitmap resource to GPU.
* @param renderer - Renderer to upload to
* @param baseTexture - BaseTexture for this resource
* @param glTexture - GLTexture to use
* @returns {boolean} true is success
*/
upload(renderer: Renderer, baseTexture: BaseTexture, glTexture: GLTexture): boolean;
/** Destroys this resource. */
dispose(): void;
/**
* Used to auto-detect the type of resource.
* @param {*} source - The source object
* @returns {boolean} `true` if current environment support ImageBitmap, and source is string or ImageBitmap
*/
static test(source: unknown): source is string | ImageBitmap;
/**
* Cached empty placeholder canvas.
* @see EMPTY
*/
private static _EMPTY;
/**
* ImageBitmap cannot be created synchronously, so a empty placeholder canvas is needed when loading from URLs.
* Only for internal usage.
* @returns The cached placeholder canvas.
*/
private static get EMPTY();
}