Drag[en]gine Script Module DragonScript  1.21
Dragengine.Gui.ImagePixels Class Reference

Image pixels. More...

Inheritance diagram for Dragengine.Gui.ImagePixels:

Public Member Functions

Constructors
ImagePixels new (Image image)
 Create ImagePixels instance to access pixel data. More...
 
Management
Image getImage ()
 Image resource. More...
 
int getWidth ()
 Width in pixels. More...
 
int getHeight ()
 Height in pixels. More...
 
int getDepth ()
 Depth in layers. More...
 
Color getAt (int x, int y)
 Color of pixel at coordinate. More...
 
Color getAt (int x, int y, int z)
 Color of pixel at coordinate. More...
 
void getRange (Array pixels, int x, int y, int width, int height)
 Range of pixels. More...
 
void getRange (Array pixels, int x, int y, int z, int width, int height, int depth)
 Range of pixels. More...
 

Detailed Description

Image pixels.

Allows obtaining pixels from image resources.

Image resources can consume a lot of CPU memory. This amount of memory is usually wasted since Graphic Modules tend to process and store the image data in GPU resources. Once stored the original image data is not required to be present in CPU memory and will be released.

This class retains the image data in memory to allow accessing the pixels data from script classes. Once the instance is destroyed the retained data is released again. For this reason when creating an instance of this class it is likely the data has to be loaded into memory. It is thus recommended to create the class instance during loading time and to keep the reference stored for as long as you need to work with the image data.

Pixels retrieved from the image are converted to full colors like this:

  • 1 component: Color.new( value, value, value, 1 )
  • 2 components: Color.new( value, value, value, alpha )
  • 3 components: Color.new( red, green, blue, 1 )
  • 4 components: Color.new( red, green, blue, alpha )

This is a native class.

Member Function Documentation

◆ getAt() [1/2]

Color Dragengine.Gui.ImagePixels.getAt ( int  x,
int  y 
)

Color of pixel at coordinate.

Exceptions
EInvalidParamx < 0.
EInvalidParamx >= image.getWidth().
EInvalidParamy < 0.
EInvalidParamy >= image.getHeight().

◆ getAt() [2/2]

Color Dragengine.Gui.ImagePixels.getAt ( int  x,
int  y,
int  z 
)

Color of pixel at coordinate.

Exceptions
EInvalidParamx < 0.
EInvalidParamx >= image.getWidth().
EInvalidParamy < 0.
EInvalidParamy >= image.getHeight().
EInvalidParamz < 0.
EInvalidParamz >= image.getDepth().

◆ getDepth()

int Dragengine.Gui.ImagePixels.getDepth ( )

Depth in layers.

◆ getHeight()

int Dragengine.Gui.ImagePixels.getHeight ( )

Height in pixels.

◆ getImage()

Image Dragengine.Gui.ImagePixels.getImage ( )

Image resource.

◆ getRange() [1/2]

void Dragengine.Gui.ImagePixels.getRange ( Array  pixels,
int  x,
int  y,
int  width,
int  height 
)

Range of pixels.

pixels is required to be of size "width * height". Content of pixels will be replaced with Color instances of the pixels in the desired range. The index of each pixel is "height * y + x".

Exceptions
ENullPointerpixels is null.
EInvalidParamx < 0.
EInvalidParamwidth < 0.
EInvalidParamx + width > image.getWidth().
EInvalidParamy < 0.
EInvalidParamheight < 0.
EInvalidParamy + height > image.getHeight().
EInvalidParampixels.getCount != width * height.

◆ getRange() [2/2]

void Dragengine.Gui.ImagePixels.getRange ( Array  pixels,
int  x,
int  y,
int  z,
int  width,
int  height,
int  depth 
)

Range of pixels.

pixels is required to be of size "width * height * depth". Content of pixels will be replaced with Color instances of the pixels in the desired range. The index of each pixel is "width * height * z + height * y + x".

Exceptions
ENullPointerpixels is null.
EInvalidParamx < 0.
EInvalidParamwidth < 0.
EInvalidParamx + width > image.getWidth().
EInvalidParamy < 0.
EInvalidParamheight < 0.
EInvalidParamy + height > image.getHeight().
EInvalidParamz < 0.
EInvalidParamdepth < 0.
EInvalidParamz + depth > image.getDepth().
EInvalidParampixels.getCount != width * height * depth.

◆ getWidth()

int Dragengine.Gui.ImagePixels.getWidth ( )

Width in pixels.

◆ new()

ImagePixels Dragengine.Gui.ImagePixels.new ( Image  image)

Create ImagePixels instance to access pixel data.

Potentially causes loading image data into memory. Upon destruction image data is released from memory.


The documentation for this class was generated from the following file: