PIXI.ImageResource
class ImageResource extends PIXI.BaseImageResource
Resource type for HTMLImageElement.
Constructor
new PIXI.ImageResource(source: HTMLImageElement | string, options: IImageResourceOptions) → {}
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source | HTMLImageElement | string |
image source or URL |
||
options | IImageResourceOptions |
<optional> |
||
options.autoLoad | boolean |
<optional> |
true |
start loading process |
options.createBitmap | boolean |
<optional> |
PIXI.settings.CREATE_IMAGE_BITMAP |
whether its required to create a bitmap before upload |
options.crossorigin | boolean |
<optional> |
true |
Load image using cross origin |
options.alphaMode | PIXI.ALPHA_MODES |
<optional> |
PIXI.ALPHA_MODES.UNPACK |
Premultiply image alpha in bitmap |
Summary
Properties from ImageResource
PIXI.ALPHA_MODES |
|
ImageBitmap |
|
boolean |
|
boolean |
|
string |
URL of the image source |
Methods from ImageResource
boolean |
|
void |
Destroys this resource. |
Promise<PIXI.ImageResource> |
|
Promise<PIXI.ImageResource> |
|
boolean |
|
Properties inherited from BaseImageResource
HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement |
|
Properties inherited from Resource
boolean |
|
number |
|
boolean |
|
string |
The url of the resource |
boolean |
|
number |
|
number |
Internal height of the resource. |
number |
Internal width of the resource. |
Methods inherited from BaseImageResource
void |
|
Methods inherited from Resource
void |
|
void |
|
void |
|
boolean |
|
void |
|
Public Properties
alphaMode: PIXI.ALPHA_MODES
Controls texture alphaMode field
Copies from options
Default is null
, copies option from baseTexture
bitmap: ImageBitmap = null
The ImageBitmap element created for a HTMLImageElement
.
createBitmap: boolean = PIXI.settings.CREATE_IMAGE_BITMAP
If capable, convert the image using createImageBitmap API.
preserveBitmap: boolean = false
If the image should be disposed after upload
Public Methods
static test(source: unknown) → {boolean}
Used to auto-detect the type of resource.
Name | Type | Description |
---|---|---|
source | unknown |
The source object |
Type | Description |
---|---|
boolean |
|
dispose() → {void}
Destroys this resource.
Type | Description |
---|---|
void |
load(createBitmap: boolean) → {Promise<PIXI.ImageResource>}
Returns a promise when image will be loaded and processed.
Name | Type | Attributes | Description |
---|---|---|---|
createBitmap | boolean |
<optional> |
whether process image into bitmap |
Type | Description |
---|---|
Promise<PIXI.ImageResource> |
process() → {Promise<PIXI.ImageResource>}
Called when we need to convert image into BitmapImage. Can be called multiple times, real promise is cached inside.
Type | Description |
---|---|
Promise<PIXI.ImageResource> |
|
upload(renderer: PIXI.Renderer, baseTexture: PIXI.BaseTexture, glTexture: PIXI.GLTexture) → {boolean}
Upload the image resource to GPU.
Name | Type | Description |
---|---|---|
renderer | PIXI.Renderer |
Renderer to upload to |
baseTexture | PIXI.BaseTexture |
BaseTexture for this resource |
glTexture | PIXI.GLTexture |
GLTexture to use |
Type | Description |
---|---|
boolean |
true is success |