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 true optional

whether its required to create a bitmap before upload defaults true

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

Internal height of the resource

_width number protected inherited

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.

onResize Runner inherited

Mini-runner for handling resize events

onUpdate Runner inherited

Mini-runner for handling update events

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 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

process ()Promise

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

Returns:
Type Description
Promise cached promise to fill that bitmap

Trigger a resize event

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.glCore.Texture

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

Has been updated trigger event

upload (renderer, baseTexture, glTexture) 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.glCore.Texture

GLTexture to use