40#ifndef ULTRALIGHT_CAPI_BITMAP_H
41#define ULTRALIGHT_CAPI_BITMAP_H
159 const void* pixels,
size_t size,
bool should_copy);
331 bool convert_to_straight_alpha);
363 bool convert_to_straight_alpha);
void * ulBitmapRawPixels(ULBitmap bitmap)
Get the raw pixel buffer.
bool ulBitmapOwnsPixels(ULBitmap bitmap)
Whether or not this bitmap owns its own pixel buffer.
bool ulBitmapWritePNG(ULBitmap bitmap, const char *path)
Write bitmap to a PNG on disk.
ULBitmap ulCreateBitmap(unsigned int width, unsigned int height, ULBitmapFormat format)
Create bitmap with certain dimensions and pixel format.
bool ulBitmapIsEmpty(ULBitmap bitmap)
Whether or not this bitmap is empty.
ULBitmap ulCreateEmptyBitmap(void)
Create an empty bitmap.
void ulDestroyBitmap(ULBitmap bitmap)
Destroy a bitmap.
bool ulBitmapIsCompressed(ULBitmap bitmap)
Whether or not this bitmap uses a block-compressed (BCn) format.
void ulBitmapUnlockPixels(ULBitmap bitmap)
Unlock pixels after locking.
unsigned int ulBitmapGetRowBytes(ULBitmap bitmap)
Get the number of bytes per row.
bool ulBitmapDrawBitmap(ULBitmap bitmap, ULIntRect src_rect, ULIntRect dest_rect, ULBitmap src, bool pad_repeat)
Draw another bitmap to this bitmap.
ULBitmapFormat ulBitmapGetFormat(ULBitmap bitmap)
Get the pixel format.
ULBitmapFormatInfo ulGetBitmapFormatInfo(ULBitmapFormat format)
Get the block geometry for a given pixel format.
unsigned int ulBitmapGetHeight(ULBitmap bitmap)
Get the height in pixels.
void ulBitmapConvertToStraightAlpha(ULBitmap bitmap)
Convert a BGRA bitmap from premultiplied alpha to straight alpha.
bool ulBitmapResample(ULBitmap bitmap, ULBitmap destination, bool high_quality)
Make a resized copy of this bitmap by writing to a pre-allocated destination bitmap.
void ulBitmapErase(ULBitmap bitmap)
Reset bitmap pixels to 0.
unsigned int ulBitmapGetWidth(ULBitmap bitmap)
Get the width in pixels.
bool ulBitmapWritePNGEx(ULBitmap bitmap, const char *path, bool convert_to_rgba, bool convert_to_straight_alpha)
Write bitmap to a PNG on disk with explicit conversion control.
void ulBitmapConvertToPremultipliedAlpha(ULBitmap bitmap)
Convert a BGRA bitmap from straight alpha to premultiplied alpha.
void * ulBitmapLockPixels(ULBitmap bitmap)
Lock the pixel buffer for reading/writing.
void ulBitmapSet(ULBitmap bitmap, ULBitmap source)
Assign another bitmap to this one.
ULBitmap ulCreateBitmapFromPixels(unsigned int width, unsigned int height, ULBitmapFormat format, unsigned int row_bytes, const void *pixels, size_t size, bool should_copy)
Create a bitmap from an existing pixel buffer.
size_t ulBitmapGetSize(ULBitmap bitmap)
Get the size in bytes of the underlying pixel buffer.
ULBuffer ulBitmapEncodePNG(ULBitmap bitmap)
Encode this bitmap as a PNG image and return the encoded bytes in a buffer.
unsigned int ulBitmapMaxDimension(void)
Get the maximum supported width or height, in pixels.
ULIntRect ulBitmapGetBounds(ULBitmap bitmap)
Get the bounds as a ULIntRect.
ULBuffer ulBitmapEncodePNGEx(ULBitmap bitmap, bool convert_to_rgba, bool convert_to_straight_alpha)
Encode this bitmap as a PNG image with explicit conversion control and return the encoded bytes in a ...
ULBitmap ulCreateBitmapAligned(unsigned int width, unsigned int height, ULBitmapFormat format, unsigned int alignment)
Create bitmap with certain dimensions, pixel format, and row byte alignment.
unsigned int ulBitmapGetBpp(ULBitmap bitmap)
Get the bytes per pixel.
bool ulIsCompressedFormat(ULBitmapFormat format)
Whether or not a given pixel format is block-compressed (a BCn format).
void ulBitmapSwapRedBlueChannels(ULBitmap bitmap)
This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
ULBitmap ulCreateBitmapFromCopy(ULBitmap existing_bitmap)
Create a bitmap from a deep copy of another bitmap.
Various defines and utility functions for the C API.
#define ULExport
Definition CAPI_Defines.h:42
struct C_Bitmap * ULBitmap
Opaque handle to a Bitmap object.
Definition CAPI_Defines.h:93
struct C_Buffer * ULBuffer
Opaque handle to a Buffer object.
Definition CAPI_Defines.h:99
ULBitmapFormat
Definition CAPI_Defines.h:164
Integer rectangle defined by left, top, right, and bottom coordinates.
Definition CAPI_Defines.h:548