Class: ImageResource

PIXI.ImageResource

Resource type for HTMLImageElement.

new PIXI.ImageResource (source, options) overrides

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

Extends

Members

alphaMode PIXI.ALPHA_MODES readonly

Controls texture alphaMode field Copies from options Default is null, copies option from baseTexture

bitmap ImageBitmap

The ImageBitmap element created for a HTMLImageElement.

Default Value:
  • null

createBitmap boolean

If capable, convert the image using createImageBitmap API.

Default Value:
  • PIXI.settings.CREATE_IMAGE_BITMAP

preserveBitmap boolean

If the image should be disposed after upload

Default Value:
  • false

url string

URL of the image source

Methods

PIXI.ImageResource.test (source) boolean static

Used to auto-detect the type of resource.

Name Type Description
source unknown

The source object

Returns:
Type Description
boolean true if source is string or HTMLImageElement

Destroys this resource.

load (createBitmap) Promise<PIXI.ImageResource> overrides

Returns a promise when image will be loaded and processed.

Name Type Attributes Description
createBitmap boolean <optional>

whether process image into bitmap

Returns:
Type Description
Promise<PIXI.ImageResource>

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

Returns:
Type Description
Promise<PIXI.ImageResource>
  • Cached promise to fill that bitmap

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

Inherited Properties

From class PIXI.BaseImageResource

source HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | SVGElement readonly inherited

The source element.

From class PIXI.Resource

destroyed boolean readonly inherited

If resource has been destroyed.

Default Value:
  • false

height number readonly inherited

The height of the resource.

internal boolean inherited

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

src string inherited

The url of the resource

valid boolean readonly inherited

Has been validated

width number readonly inherited

The width of the resource.

_height number protected inherited

Internal height of the resource.

_width number protected inherited

Internal width of the resource.

Inherited Methods

From class PIXI.BaseImageResource

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

From class PIXI.Resource

bind (baseTexture) void inherited

Bind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture

destroy () void inherited

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

resize (width, height) void 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) void inherited

Unbind to a parent BaseTexture

Name Type Description
baseTexture PIXI.BaseTexture

Parent texture