The comfortable framework for making games in Wren
This set of APIs allows you to load and manage graphics from supported file formats. (See the graphics module for more information.)
BITMAP_API_v0* bitmap = (BITMAP_API_v0*)DOME_getAPI(API_BITMAP, BITMAP_API_VERSION);
The DOME_Bitmap type contains the following fields:
Field | Type | Purpose |
---|---|---|
width | int32_t | Width of the bitmap in pixels. |
height | int32_t | Height of the bitmap in pixels. |
pixels | DOME_Color* | Pointer to the first pixel of the bitmap. |
DOME_Bitmap* fromFile(DOME_Context ctx, const char* path)
Loads an image file from path
on disk (relative to the application entry point)
and returns a DOME_Bitmap
. You are responsible for freeing it using the free
function in this API.
If there is a problem with the file, this method will return NULL
. You can find out why
using core->getLastError(DOME_Context ctx)
;
DOME_Bitmap* fromFileInMemory(DOME_Context ctx, void* buffer, size_t length)
Loads an image file stored in memory at buffer
, with a size of length
, and
returns a DOME_Bitmap
. You are responsible for freeing it using the free
function in this API.
If there is a problem with the file, this method will return NULL
. You can find out why
using core->getLastError(DOME_Context ctx)
;
void free(DOME_Bitmap* bitmap)
Safely frees the bitmap
. Make sure you don’t attempt to use the bitmap
pointer
after this function returns.
DOME_Color pget(DOME_Bitmap* bitmap, uint32_t x, uint32_t y)
Returns the color of the pixel located at (x, y)
in bitmap
.
void pset(DOME_Bitmap* bitmap, uint32_t x, uint32_t y, DOME_Color color)
Sets the color of the pixel located at (x, y)
in bitmap
to color
.