docs
Loading...
Searching...
No Matches
CAPI_Bitmap.h

Overview

A thread-safe container for pixel data.

#include <Ultralight/CAPI/CAPI_Bitmap.h>

The bitmap class is used to store pixel data in a variety of formats. It intelligently manages the lifetime of the pixel buffer and provides thread-safe access to the pixel data.

Accessing Pixel Data

To access the pixel data, you must first lock the pixels using ulBitmapLockPixels(). This will return a pointer to the pixel buffer. An example follows:

void* pixels = ulBitmapLockPixels(bitmap);
if (pixels) {
// Zero out the pixel buffer
memset(pixels, 0, ulBitmapGetSize(bitmap));
}
// Unlock the pixels when you're done.
void ulBitmapUnlockPixels(ULBitmap bitmap)
Unlock pixels after locking.
void * ulBitmapLockPixels(ULBitmap bitmap)
Lock pixels for reading/writing, returns pointer to pixel buffer.
size_t ulBitmapGetSize(ULBitmap bitmap)
Get the size in bytes of the underlying pixel buffer.

Functions

ULBitmap ulCreateEmptyBitmap ()
 Create empty bitmap.
ULBitmap ulCreateBitmap (unsigned int width, unsigned int height, ULBitmapFormat format)
 Create bitmap with certain dimensions and pixel format.
ULBitmap ulCreateBitmapFromPixels (unsigned int width, unsigned int height, ULBitmapFormat format, unsigned int row_bytes, const void *pixels, size_t size, bool should_copy)
 Create bitmap from existing pixel buffer.
ULBitmap ulCreateBitmapFromCopy (ULBitmap existing_bitmap)
 Create bitmap from copy.
void ulDestroyBitmap (ULBitmap bitmap)
 Destroy a bitmap (you should only destroy Bitmaps you have explicitly created via one of the creation functions above.
unsigned int ulBitmapGetWidth (ULBitmap bitmap)
 Get the width in pixels.
unsigned int ulBitmapGetHeight (ULBitmap bitmap)
 Get the height in pixels.
ULBitmapFormat ulBitmapGetFormat (ULBitmap bitmap)
 Get the pixel format.
unsigned int ulBitmapGetBpp (ULBitmap bitmap)
 Get the bytes per pixel.
unsigned int ulBitmapGetRowBytes (ULBitmap bitmap)
 Get the number of bytes per row.
size_t ulBitmapGetSize (ULBitmap bitmap)
 Get the size in bytes of the underlying pixel buffer.
bool ulBitmapOwnsPixels (ULBitmap bitmap)
 Whether or not this bitmap owns its own pixel buffer.
void * ulBitmapLockPixels (ULBitmap bitmap)
 Lock pixels for reading/writing, returns pointer to pixel buffer.
void ulBitmapUnlockPixels (ULBitmap bitmap)
 Unlock pixels after locking.
void * ulBitmapRawPixels (ULBitmap bitmap)
 Get raw pixel buffer– you should only call this if Bitmap is already locked.
bool ulBitmapIsEmpty (ULBitmap bitmap)
 Whether or not this bitmap is empty.
void ulBitmapErase (ULBitmap bitmap)
 Reset bitmap pixels to 0.
bool ulBitmapWritePNG (ULBitmap bitmap, const char *path)
 Write bitmap to a PNG on disk.
void ulBitmapSwapRedBlueChannels (ULBitmap bitmap)
 This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.

Function Documentation

◆ ulBitmapErase()

void ulBitmapErase ( ULBitmap bitmap)

Reset bitmap pixels to 0.

◆ ulBitmapGetBpp()

unsigned int ulBitmapGetBpp ( ULBitmap bitmap)

Get the bytes per pixel.

◆ ulBitmapGetFormat()

ULBitmapFormat ulBitmapGetFormat ( ULBitmap bitmap)

Get the pixel format.

◆ ulBitmapGetHeight()

unsigned int ulBitmapGetHeight ( ULBitmap bitmap)

Get the height in pixels.

◆ ulBitmapGetRowBytes()

unsigned int ulBitmapGetRowBytes ( ULBitmap bitmap)

Get the number of bytes per row.

◆ ulBitmapGetSize()

size_t ulBitmapGetSize ( ULBitmap bitmap)

Get the size in bytes of the underlying pixel buffer.

◆ ulBitmapGetWidth()

unsigned int ulBitmapGetWidth ( ULBitmap bitmap)

Get the width in pixels.

◆ ulBitmapIsEmpty()

bool ulBitmapIsEmpty ( ULBitmap bitmap)

Whether or not this bitmap is empty.

◆ ulBitmapLockPixels()

void * ulBitmapLockPixels ( ULBitmap bitmap)

Lock pixels for reading/writing, returns pointer to pixel buffer.

◆ ulBitmapOwnsPixels()

bool ulBitmapOwnsPixels ( ULBitmap bitmap)

Whether or not this bitmap owns its own pixel buffer.

◆ ulBitmapRawPixels()

void * ulBitmapRawPixels ( ULBitmap bitmap)

Get raw pixel buffer– you should only call this if Bitmap is already locked.

◆ ulBitmapSwapRedBlueChannels()

void ulBitmapSwapRedBlueChannels ( ULBitmap bitmap)

This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.

◆ ulBitmapUnlockPixels()

void ulBitmapUnlockPixels ( ULBitmap bitmap)

Unlock pixels after locking.

◆ ulBitmapWritePNG()

bool ulBitmapWritePNG ( ULBitmap bitmap,
const char * path )

Write bitmap to a PNG on disk.

◆ ulCreateBitmap()

ULBitmap ulCreateBitmap ( unsigned int width,
unsigned int height,
ULBitmapFormat format )

Create bitmap with certain dimensions and pixel format.

◆ ulCreateBitmapFromCopy()

ULBitmap ulCreateBitmapFromCopy ( ULBitmap existing_bitmap)

Create bitmap from copy.

◆ ulCreateBitmapFromPixels()

ULBitmap ulCreateBitmapFromPixels ( unsigned int width,
unsigned int height,
ULBitmapFormat format,
unsigned int row_bytes,
const void * pixels,
size_t size,
bool should_copy )

Create bitmap from existing pixel buffer.

See also
Bitmap for help using this function.

◆ ulCreateEmptyBitmap()

ULBitmap ulCreateEmptyBitmap ( )

Create empty bitmap.

◆ ulDestroyBitmap()

void ulDestroyBitmap ( ULBitmap bitmap)

Destroy a bitmap (you should only destroy Bitmaps you have explicitly created via one of the creation functions above.

Go to the source code of this file.