Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Page
Library
Module
Module type
Parameter
Class
Class type
Source
V1.ImageData
SourceImage data manipulation functions
An abstract type representing an image data
create size
creates an empty image data of the given size
.
Exceptions:
Exception.Not_initialized
if Backend.init
was not calledInvalid_argument
if either component of size
is outside the range 1-32767createFromPNG filename
creates an image data with the contents of PNG file filename
. The returned event will be triggered once the image is loaded.
Exceptions:
Exception.Not_initialized
if Backend.init
was not calledException.Read_png_failed
if the PNG file could not be readsub c ~pos ~size
returns a copy of the pixel data at position pos
of size size
in image data id
. Any pixel outside the image bounds is considered to be transparent black.
Exceptions:
Invalid_argument
if either component of size
is outside the range 1-32767blit ~dst ~dpos ~src ~spos ~size
copies the area specified by spos
and size
from image data src
to image data dst
at position dpos
. If the given position and size yield an inconsistent area, this has no effect.
Exceptions:
Invalid_argument
if either component of size
is outside the range 1-32767getPixel id pos
returns the color of the pixel at position pos
in image data id
. If pos
is outside the image bounds, returns the transparent black color.
putPixel id pos c
sets the color of the pixel at position pos
in image data id
to color c
. If pos
is outside the image bounds, this has no effect.
importPNG id ~pos filename
loads the file filename
into image data id
at position pos
. Any pixel that falls outside the image bounds is ignored. The returned event will be triggered once the image is loaded.
Exceptions:
Exception.Not_initialized
if Backend.init
was not calledException.Read_png_failed
if the PNG file could not be readexportPNG id filename
saves the contents of image data id
to a file with name filename
Exceptions:
Exception.Not_initialized
if Backend.init
was not calledException.Write_png_failed
if the PNG file could not be writtenImage data's internal representation is a big array of dimension 3 (height, width, component), with the components in BGRA order
of_bigarray ba
reinterprets a big array ba
as an image data. The big array must be of dimension 3 (height, width, component), with the components in BGRA order. The underlying memory will be shared between the image data and the big array.
Exceptions:
Invalid_argument
if the first or second dimension of ba
is outside the range 1-32767, or if the third dimension of ba
is not 4