Class: ImageResource

PIXI.resources.ImageResource

Resource type for HTMLImageElement.

new PIXI.resources.ImageResource (source)

Name Type Default Description
source HTMLImageElement | string

image source or URL

options.autoLoad boolean true optional

start loading process

options.createBitmap boolean PIXI.settings.CREATE_IMAGE_BITMAP optional

whether its required to create a bitmap before upload

options.crossorigin boolean true optional

Load image using cross origin

options.premultiplyAlpha boolean true optional

Premultiply image alpha in bitmap

Extends

Members

_height number protected inherited overrides

Internal height of the resource

_width number protected inherited overrides

Internal width of the resource

bitmap ImageBitmap

The ImageBitmap element created for HTMLImageElement

Default Value:
  • null

createBitmap boolean

If capable, convert the image using createImageBitmap API

Default Value:
  • PIXI.settings.CREATE_IMAGE_BITMAP

destroyed boolean readonly inherited

If resource has been destroyed

Default Value:
  • false

height number readonly inherited

The height of the resource.

internal boolean protected inherited

true if resource is created by BaseTexture useful for doing cleanup with BaseTexture destroy and not cleaning up resources that were created externally.

premultiplyAlpha boolean | null readonly

Controls texture premultiplyAlpha field Copies from options

preserveBitmap boolean

If the image should be disposed after upload

Default Value:
  • false

source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement readonly inherited

The source element

url string

URL of the image source

valid boolean readonly inherited

Has been validated

width number readonly inherited

The width of the resource.

Methods

bind (baseTexture) inherited

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Call when destroying resource, unbind any BaseTexture object before calling this method, as reference counts are maintained internally.

dispose () protected inherited overrides

Clean up anything, this happens when destroying is ready.

load (createBitmap)Promise.<void> overrides

returns a promise when image will be loaded and processed

Name Type Default Description
createBitmap boolean true optional

whether process image into bitmap

Returns:
Type Description
Promise.<void>

process ()Promise.<void>

Called when we need to convert image into BitmapImage. Can be called multiple times, real promise is cached inside.

Returns:
Type Description
Promise.<void> cached promise to fill that bitmap

resize (width, height) inherited

Trigger a resize event

Name Type Description
width number

X dimension

height number

Y dimension

style (renderer, baseTexture, glTexture)boolean inherited

Set the style, optional to override

Name Type Description
renderer PIXI.Renderer

yeah, renderer!

baseTexture PIXI.BaseTexture

the texture

glTexture PIXI.GLTexture

texture instance for this webgl context

Returns:
Type Description
boolean true is success

unbind (baseTexture) inherited

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

Checks if source width/height was changed, resize can cause extra baseTexture update. Triggers one update in any case.

upload (renderer, baseTexture, glTexture)boolean overrides

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

Returns:
Type Description
boolean true is success