Module OgamlGraphics.Image

Image manipulation and creation

This module provides a safe way to load and access images stored in the RAM. Images stored this way are uncompressed arrays of bytes and are therefore not meant to be stored in large quantities.

exception Image_error of string
Raised when an error occur in this module
type t
Type of an image stored in the RAM
val create : [ `File of string | `Empty of (OgamlMath.Vector2i.t * Color.t) | `Data of (OgamlMath.Vector2i.t * Bytes.t)] -> t
Creates an image from a file, some RGBA-formatted data, or an empty one filled with a default color
Raises Image_error if the loading fails
See : OgamlGraphics.Color
val size : t -> OgamlMath.Vector2i.t
Return the size of an image
val set : t -> OgamlMath.Vector2i.t -> Color.t -> unit
Sets a pixel of an image
See : OgamlGraphics.Color
val get : t -> OgamlMath.Vector2i.t -> Color.RGB.t
Gets the color of a pixel of an image
See : OgamlGraphics.Color.RGB
val blit : t -> ?rect:OgamlMath.IntRect.t -> t -> OgamlMath.Vector2i.t -> unit
blit src ~rect dest offset blits the subimage of src defined by rect on the image dest at position offset (relative to the top-left pixel).
If rect is not provided then the whole image src is used.
See : OgamlMath.IntRect
See : OgamlMath.Vector2i
val mipmap : t -> int -> t
mipmap img lvl returns a new, fresh image that is the lvl -th reduction of the image img
val pad : t -> ?offset:OgamlMath.Vector2i.t -> ?color:Color.t -> OgamlMath.Vector2i.t -> t
pad img offset color size returns a new image of size size , which contains img placed at position offset , and where the empty pixels are filled with color