Drag[en]gine Script Module DragonScript
1.23
|
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... | |
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:
This is a native class.
Color Dragengine.Gui.ImagePixels.getAt | ( | int | x, |
int | y | ||
) |
Color of pixel at coordinate.
EInvalidParam | x < 0. |
EInvalidParam | x >= image.getWidth(). |
EInvalidParam | y < 0. |
EInvalidParam | y >= image.getHeight(). |
Color Dragengine.Gui.ImagePixels.getAt | ( | int | x, |
int | y, | ||
int | z | ||
) |
Color of pixel at coordinate.
EInvalidParam | x < 0. |
EInvalidParam | x >= image.getWidth(). |
EInvalidParam | y < 0. |
EInvalidParam | y >= image.getHeight(). |
EInvalidParam | z < 0. |
EInvalidParam | z >= image.getDepth(). |
int Dragengine.Gui.ImagePixels.getDepth | ( | ) |
Depth in layers.
int Dragengine.Gui.ImagePixels.getHeight | ( | ) |
Height in pixels.
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".
ENullPointer | pixels is null. |
EInvalidParam | x < 0. |
EInvalidParam | width < 0. |
EInvalidParam | x + width > image.getWidth(). |
EInvalidParam | y < 0. |
EInvalidParam | height < 0. |
EInvalidParam | y + height > image.getHeight(). |
EInvalidParam | pixels.getCount != width * height. |
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".
ENullPointer | pixels is null. |
EInvalidParam | x < 0. |
EInvalidParam | width < 0. |
EInvalidParam | x + width > image.getWidth(). |
EInvalidParam | y < 0. |
EInvalidParam | height < 0. |
EInvalidParam | y + height > image.getHeight(). |
EInvalidParam | z < 0. |
EInvalidParam | depth < 0. |
EInvalidParam | z + depth > image.getDepth(). |
EInvalidParam | pixels.getCount != width * height * depth. |
int Dragengine.Gui.ImagePixels.getWidth | ( | ) |
Width in pixels.
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.