Skip to content
Alessandro Febretti edited this page Jul 4, 2016 · 17 revisions

Last revision: ver. 14.3 - 3 July 2016

module omega wraps omega::PixelData

Methods

Method(s) Description
static PixelData create(int width, int height, Format fmt) Creates a new pixel data object. For format, see bottom of this page.
getWidth(), getHeight() Returns the width and height in pixels of the specified image
beginPixelAccess() Starts reading / writing pixels. The pixel access methods are available only after this call.
endPixelAccess() Stops reading / writing pixels.
int getPixelR(int x, int y) Read the red component of the pixel at the specified position. Returns -1 if the pixel is out of bounds. The value is returned as a byte (0-255)
int getPixelG(int x, int y) Read the green component of the pixel at the specified position. Returns -1 if the pixel is out of bounds. The value is returned as a byte (0-255)
int getPixelB(int x, int y) Read the green component of the pixel at the specified position. Returns -1 if the pixel is out of bounds. The value is returned as a byte (0-255)
int getPixelA(int x, int y) Read the green component of the pixel at the specified position. Return 255 if the image has no alpha channel. Returns -1 if the pixel is out of bounds. The value is returned as a byte (0-255)
setPixel(int x, int y, int r, int g, int b, int a) Set a pixel at the specified position. Pixel components should be specified as byte values (0-255). Alpha is ignored for images without an alpha channel.
(v6.0) resize(int width, int height) Resets this pixeldata object to a new width/height. Data currently contained in the pixel data object will be deleted
(v10.2) bool isDirty(), setDirty(bool dirty) gets or sets the dirty flag on this pixel data object. A dirty flag set ensures any graphic object using this PixelData will refresh.

Global Functions

PixelData loadImage(filename)

Loads an image given a file path. If loading is succesfull, returns an instance of PixelData. If loading fails, return None

(v7.2) bool saveImage(PixelData image, string file, ImageFormat fmt)

Saves the pixel data to an image file with the specified format. See the ImageFormat section for a list of supported formats. If saving succeeds, returns True.

setImageLoaderThreads(int threads), getImageLoaderThreads()

Gets or sets the number of threads used for asynchronous image loading. Async image loading is currently available only for native code modules.

Supported Formats

Pixel data formats are listed in the PixelFormat enumeration. Valid values are:

  • FormatRgb
  • FormatRgba
  • (v14.3) 'FormatBgra'
  • FormatMonochrome

Image Formats

The ImageFormat enumeration can be used to specify an image file encoding. Supported values are:

  • FormatPng
  • FormatJpeg
Clone this wiki locally