Banjo API 0.0.1
Multi-purpose C99 API
|
Macros | |
#define | BJ_PIXEL_TYPE_INDEX 0x01 |
Pixel type: Indexed (palette-based). | |
#define | BJ_PIXEL_TYPE_BITFIELD 0x02 |
Pixel type: Bitfield representation (e.g., RGB565). | |
#define | BJ_PIXEL_TYPE_BYTES 0x03 |
Pixel type: Byte-packed representation (e.g., RGBA8888). | |
#define | BJ_PIXEL_ORDER_RGB 0x01 |
Pixel order: Red-Green-Blue (RGB). | |
#define | BJ_PIXEL_ORDER_XRGB BJ_PIXEL_ORDER_RGB |
Pixel order: Same as BJ_PIXEL_ORDER_RGB with unused alpha. | |
#define | BJ_PIXEL_ORDER_BGR 0x02 |
Pixel order: Blue-Green-Red (BGR). | |
#define | BJ_PIXEL_ORDER_XBGR BJ_PIXEL_ORDER_BGR |
Pixel order: Same as BJ_PIXEL_ORDER_BGR with unused alpha. | |
#define | BJ_PIXEL_ORDER_RGBX 0x03 |
Pixel order: Red-Green-Blue with padding byte (RGBX). | |
#define | BJ_PIXEL_ORDER_BGRX 0x04 |
Pixel order: Blue-Green-Red with padding byte (BGRX). | |
#define | BJ_PIXEL_ORDER_ARGB 0x05 |
Pixel order: Alpha-Red-Green-Blue (ARGB). | |
#define | BJ_PIXEL_ORDER_ABGR 0x06 |
Pixel order: Alpha-Blue-Green-Red (ABGR). | |
#define | BJ_PIXEL_ORDER_RGBA 0x07 |
Pixel order: Red-Green-Blue-Alpha (RGBA). | |
#define | BJ_PIXEL_ORDER_BGRA 0x08 |
Pixel order: Blue-Green-Red-Alpha (BGRA). | |
#define | BJ_PIXEL_LAYOUT_1555 0x00 |
Pixel layout: 16-bit with 1-bit alpha, 5-bit red, green, and blue (1555). | |
#define | BJ_PIXEL_LAYOUT_8888 0x01 |
Pixel layout: 32-bit with 8 bits per channel (8888). | |
#define | BJ_PIXEL_LAYOUT_565 0x02 |
Pixel layout: 16-bit with 5 bits for red and blue, 6 bits for green (565). | |
#define | BJ_PIXEL_MODE_MAKE(bpp, type, layout, order) |
Creates a pixel format mode from bits-per-pixel, type, layout, and order. | |
#define | BJ_PIXEL_MODE_MAKE_INDEXED(bpp) |
Creates a pixel format for indexed (palette-based) pixels. | |
#define | BJ_PIXEL_MODE_MAKE_BITFIELD_16(layout, order) |
Creates a 16-bit bitfield pixel format. | |
#define | BJ_PIXEL_MODE_MAKE_BITFIELD_32(layout, order) |
Creates a 32-bit bitfield pixel format. | |
#define | BJ_PIXEL_MODE_MAKE_BYTES(bpp, order) |
Creates a byte-packed pixel format. | |
#define | BJ_PIXEL_GET_BPP(fmt) |
Extracts the bits-per-pixel from a pixel format. | |
#define | BJ_PIXEL_GET_TYPE(fmt) |
Extracts the pixel type from a pixel format. | |
#define | BJ_PIXEL_GET_LAYOUT(fmt) |
Extracts the pixel layout from a pixel format. | |
#define | BJ_PIXEL_GET_ORDER(fmt) |
Extracts the pixel order from a pixel format. | |
Enumerations | |
enum | bj_pixel_mode { BJ_PIXEL_MODE_UNKNOWN = 0x00u , BJ_PIXEL_MODE_INDEXED_1 = 0x00000101u , BJ_PIXEL_MODE_INDEXED_4 = 0x00000104u , BJ_PIXEL_MODE_INDEXED_8 = 0x00000108u , BJ_PIXEL_MODE_XRGB1555 = 0x01000210u , BJ_PIXEL_MODE_RGB565 = 0x01020210u , BJ_PIXEL_MODE_XRGB8888 = 0x01010220u , BJ_PIXEL_MODE_BGR24 = 0x02000318u } |
Representation of a pixel encoding. More... | |
Functions | |
void | bj_pixel_rgb (bj_pixel_mode mode, uint32_t value, uint8_t *p_red, uint8_t *p_green, uint8_t *p_blue) |
Gets the RGB value of a pixel given its 32-bits representation. | |
uint32_t | bj_pixel_value (bj_pixel_mode mode, uint8_t red, uint8_t green, uint8_t blue) |
Returns an opaque value representing a pixel color, given its RGB composition. | |
int | bj_compute_pixel_mode (uint8_t bpp, uint32_t red_mask, uint32_t green_mask, uint32_t blue_mask) |
Determine the most suitable bj_pixel_mode from a set of masks. | |
size_t | bj_compute_bitmap_stride (size_t width, bj_pixel_mode mode) |
Returns the stride used for encoding a bitmaps in Banjo. | |
#define BJ_PIXEL_GET_BPP | ( | fmt | ) |
fmt | Pixel format value. |
#define BJ_PIXEL_GET_LAYOUT | ( | fmt | ) |
fmt | Pixel format value. |
#define BJ_PIXEL_GET_ORDER | ( | fmt | ) |
fmt | Pixel format value. |
#define BJ_PIXEL_GET_TYPE | ( | fmt | ) |
fmt | Pixel format value. |
#define BJ_PIXEL_MODE_MAKE | ( | bpp, | |
type, | |||
layout, | |||
order ) |
bpp | Bits-per-pixel. |
type | Pixel type (e.g., indexed, bitfield, or bytes). |
layout | Pixel layout (e.g., 1555, 8888, or 565). |
order | Pixel order (e.g., RGB, ARGB, etc.). |
#define BJ_PIXEL_MODE_MAKE_BITFIELD_16 | ( | layout, | |
order ) |
layout | Pixel layout (e.g., 1555, 565). |
order | Pixel order (e.g., RGB, ARGB). |
#define BJ_PIXEL_MODE_MAKE_BITFIELD_32 | ( | layout, | |
order ) |
layout | Pixel layout (e.g., 8888). |
order | Pixel order (e.g., RGB, ARGB). |
#define BJ_PIXEL_MODE_MAKE_BYTES | ( | bpp, | |
order ) |
bpp | Bits-per-pixel. |
order | Pixel order (e.g., RGB, ARGB). |
#define BJ_PIXEL_MODE_MAKE_INDEXED | ( | bpp | ) |
bpp | Bits-per-pixel. |
enum bj_pixel_mode |
size_t bj_compute_bitmap_stride | ( | size_t | width, |
bj_pixel_mode | mode ) |
In a bitmap, the stride is the actual number of bytes used to encode a single row of pixels. Hence, the total size needed for a bitmap of width
x height
encoded with mode
is equal to bj_compute_bitmap_stride(width, mode) * height
.
Banjo uses the bits-per-pixel information from mode
to compute the stride and aligns the byte count to 4.
width | The width in pixel of a row |
mode | The pixel mode |
int bj_compute_pixel_mode | ( | uint8_t | bpp, |
uint32_t | red_mask, | ||
uint32_t | green_mask, | ||
uint32_t | blue_mask ) |
This function can be used to retrieve what Banjo consider as the pixel mode corresponding to a given depth and masks.
If not suitable pixel mode is found, BJ_PIXEL_MODE_UNKNOWN is returned.
bpp | The number of bits used to encode a pixel. |
red_mask | A bitmask for the red channel information in the bits. |
green_mask | A bitmask for the green channel information in the bits. |
blue_mask | A bitmask for the blue channel information in the bits. |
void bj_pixel_rgb | ( | bj_pixel_mode | mode, |
uint32_t | value, | ||
uint8_t * | p_red, | ||
uint8_t * | p_green, | ||
uint8_t * | p_blue ) |
mode | The pixel mode |
value | The opaque pixel value |
p_red | A location to the red component |
p_green | A location to the green component |
p_blue | A location to the blue component |
uint32_t bj_pixel_value | ( | bj_pixel_mode | mode, |
uint8_t | red, | ||
uint8_t | green, | ||
uint8_t | blue ) |
mode | The pixel mode |
red | The red component of the color |
green | The green component of the color |
blue | The blue component of the color |
uint32_t
value.