Ultralight C API 1.3.0
Loading...
Searching...
No Matches
CAPI_Bitmap.h
Go to the documentation of this file.
1/******************************************************************************
2 * This file is a part of Ultralight, an ultra-portable web-browser engine. *
3 * *
4 * See <https://ultralig.ht> for licensing and more. *
5 * *
6 * (C) 2023 Ultralight, Inc. *
7 *****************************************************************************/
8#ifndef ULTRALIGHT_CAPI_BITMAP_H
9#define ULTRALIGHT_CAPI_BITMAP_H
10
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/******************************************************************************
18 * Bitmap
19 *****************************************************************************/
20
21///
22/// Create empty bitmap.
23///
25
26///
27/// Create bitmap with certain dimensions and pixel format.
28///
29ULExport ULBitmap ulCreateBitmap(unsigned int width, unsigned int height, ULBitmapFormat format);
30
31///
32/// Create bitmap from existing pixel buffer. @see Bitmap for help using this function.
33///
34ULExport ULBitmap ulCreateBitmapFromPixels(unsigned int width, unsigned int height,
35 ULBitmapFormat format, unsigned int row_bytes,
36 const void* pixels, size_t size, bool should_copy);
37
38///
39/// Create bitmap from copy.
40///
42
43///
44/// Destroy a bitmap (you should only destroy Bitmaps you have explicitly created via one of the
45/// creation functions above.
46///
48
49///
50/// Get the width in pixels.
51///
52ULExport unsigned int ulBitmapGetWidth(ULBitmap bitmap);
53
54///
55/// Get the height in pixels.
56///
57ULExport unsigned int ulBitmapGetHeight(ULBitmap bitmap);
58
59///
60/// Get the pixel format.
61///
63
64///
65/// Get the bytes per pixel.
66///
67ULExport unsigned int ulBitmapGetBpp(ULBitmap bitmap);
68
69///
70/// Get the number of bytes per row.
71///
73
74///
75/// Get the size in bytes of the underlying pixel buffer.
76///
78
79///
80/// Whether or not this bitmap owns its own pixel buffer.
81///
83
84///
85/// Lock pixels for reading/writing, returns pointer to pixel buffer.
86///
88
89///
90/// Unlock pixels after locking.
91///
93
94///
95/// Get raw pixel buffer-- you should only call this if Bitmap is already locked.
96///
98
99///
100/// Whether or not this bitmap is empty.
101///
103
104///
105/// Reset bitmap pixels to 0.
106///
108
109///
110/// Write bitmap to a PNG on disk.
111///
112ULExport bool ulBitmapWritePNG(ULBitmap bitmap, const char* path);
113
114///
115/// This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
116///
118
119#ifdef __cplusplus
120} // extern "C"
121#endif
122
123#endif // ULTRALIGHT_CAPI_BITMAP_H
ULExport bool ulBitmapIsEmpty(ULBitmap bitmap)
Whether or not this bitmap is empty.
ULExport bool ulBitmapWritePNG(ULBitmap bitmap, const char *path)
Write bitmap to a PNG on disk.
ULExport bool ulBitmapOwnsPixels(ULBitmap bitmap)
Whether or not this bitmap owns its own pixel buffer.
ULExport ULBitmapFormat ulBitmapGetFormat(ULBitmap bitmap)
Get the pixel format.
ULExport unsigned int ulBitmapGetWidth(ULBitmap bitmap)
Get the width in pixels.
ULExport void ulBitmapErase(ULBitmap bitmap)
Reset bitmap pixels to 0.
ULExport 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.
ULExport size_t ulBitmapGetSize(ULBitmap bitmap)
Get the size in bytes of the underlying pixel buffer.
ULExport void ulBitmapUnlockPixels(ULBitmap bitmap)
Unlock pixels after locking.
ULExport unsigned int ulBitmapGetBpp(ULBitmap bitmap)
Get the bytes per pixel.
ULExport void ulDestroyBitmap(ULBitmap bitmap)
Destroy a bitmap (you should only destroy Bitmaps you have explicitly created via one of the creation...
ULExport unsigned int ulBitmapGetHeight(ULBitmap bitmap)
Get the height in pixels.
ULExport ULBitmap ulCreateBitmapFromCopy(ULBitmap existing_bitmap)
Create bitmap from copy.
ULExport void * ulBitmapLockPixels(ULBitmap bitmap)
Lock pixels for reading/writing, returns pointer to pixel buffer.
ULExport ULBitmap ulCreateEmptyBitmap()
Create empty bitmap.
ULExport void ulBitmapSwapRedBlueChannels(ULBitmap bitmap)
This converts a BGRA bitmap to RGBA bitmap and vice-versa by swapping the red and blue channels.
ULExport unsigned int ulBitmapGetRowBytes(ULBitmap bitmap)
Get the number of bytes per row.
ULExport ULBitmap ulCreateBitmap(unsigned int width, unsigned int height, ULBitmapFormat format)
Create bitmap with certain dimensions and pixel format.
ULExport void * ulBitmapRawPixels(ULBitmap bitmap)
Get raw pixel buffer– you should only call this if Bitmap is already locked.
#define ULExport
Definition CAPI_Defines.h:27
struct C_Bitmap * ULBitmap
Definition CAPI_Defines.h:53
ULBitmapFormat
Definition CAPI_Defines.h:135