Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
Pixel Definition
Collaboration diagram for Pixel Definition:

Detailed Description

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.
 

Macro Definition Documentation

◆ BJ_PIXEL_GET_BPP

#define BJ_PIXEL_GET_BPP ( fmt)
Value:
((fmt) & 0xFF)
Parameters
fmtPixel format value.

◆ BJ_PIXEL_GET_LAYOUT

#define BJ_PIXEL_GET_LAYOUT ( fmt)
Value:
(((fmt) >> 16) & 0xFF)
Parameters
fmtPixel format value.

◆ BJ_PIXEL_GET_ORDER

#define BJ_PIXEL_GET_ORDER ( fmt)
Value:
(((fmt) >> 24) & 0xFF)
Parameters
fmtPixel format value.

◆ BJ_PIXEL_GET_TYPE

#define BJ_PIXEL_GET_TYPE ( fmt)
Value:
(((fmt) >> 8) & 0xFF)
Parameters
fmtPixel format value.

◆ BJ_PIXEL_MODE_MAKE

#define BJ_PIXEL_MODE_MAKE ( bpp,
type,
layout,
order )
Value:
(((order & 0xFF) << 24) | ((layout & 0xFF) << 16) | ((type & 0xFF) << 8) | (bpp & 0xFF))
Parameters
bppBits-per-pixel.
typePixel type (e.g., indexed, bitfield, or bytes).
layoutPixel layout (e.g., 1555, 8888, or 565).
orderPixel order (e.g., RGB, ARGB, etc.).

◆ BJ_PIXEL_MODE_MAKE_BITFIELD_16

#define BJ_PIXEL_MODE_MAKE_BITFIELD_16 ( layout,
order )
Value:
#define BJ_PIXEL_MODE_MAKE(bpp, type, layout, order)
Creates a pixel format mode from bits-per-pixel, type, layout, and order.
Definition pixel.h:148
#define BJ_PIXEL_TYPE_BITFIELD
Pixel type: Bitfield representation (e.g., RGB565).
Definition pixel.h:109
Parameters
layoutPixel layout (e.g., 1555, 565).
orderPixel order (e.g., RGB, ARGB).

◆ BJ_PIXEL_MODE_MAKE_BITFIELD_32

#define BJ_PIXEL_MODE_MAKE_BITFIELD_32 ( layout,
order )
Value:
Parameters
layoutPixel layout (e.g., 8888).
orderPixel order (e.g., RGB, ARGB).

◆ BJ_PIXEL_MODE_MAKE_BYTES

#define BJ_PIXEL_MODE_MAKE_BYTES ( bpp,
order )
Value:
#define BJ_PIXEL_TYPE_BYTES
Pixel type: Byte-packed representation (e.g., RGBA8888).
Definition pixel.h:111
Parameters
bppBits-per-pixel.
orderPixel order (e.g., RGB, ARGB).

◆ BJ_PIXEL_MODE_MAKE_INDEXED

#define BJ_PIXEL_MODE_MAKE_INDEXED ( bpp)
Value:
#define BJ_PIXEL_TYPE_INDEX
Pixel type: Indexed (palette-based).
Definition pixel.h:107
Parameters
bppBits-per-pixel.

Enumeration Type Documentation

◆ bj_pixel_mode

Enumerator
BJ_PIXEL_MODE_UNKNOWN 

Unknown/Invalid pixel mode.

BJ_PIXEL_MODE_INDEXED_1 

1bpp indexed

BJ_PIXEL_MODE_INDEXED_4 

4bpp indexed

BJ_PIXEL_MODE_INDEXED_8 

8bpp indexed

BJ_PIXEL_MODE_XRGB1555 

16bpp 555-RGB

BJ_PIXEL_MODE_RGB565 

16bpp 565-RGB

BJ_PIXEL_MODE_XRGB8888 

32bpp RGB

BJ_PIXEL_MODE_BGR24 

24bpp BGR

Function Documentation

◆ bj_compute_bitmap_stride()

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.

Parameters
widthThe width in pixel of a row
modeThe pixel mode
Returns
The bitmap stride in bytes

◆ bj_compute_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.

Parameters
bppThe number of bits used to encode a pixel.
red_maskA bitmask for the red channel information in the bits.
green_maskA bitmask for the green channel information in the bits.
blue_maskA bitmask for the blue channel information in the bits.
Returns
A bj_pixel_mode value.

◆ bj_pixel_rgb()

void bj_pixel_rgb ( bj_pixel_mode mode,
uint32_t value,
uint8_t * p_red,
uint8_t * p_green,
uint8_t * p_blue )
Parameters
modeThe pixel mode
valueThe opaque pixel value
p_redA location to the red component
p_greenA location to the green component
p_blueA location to the blue component

◆ bj_pixel_value()

uint32_t bj_pixel_value ( bj_pixel_mode mode,
uint8_t red,
uint8_t green,
uint8_t blue )
Parameters
modeThe pixel mode
redThe red component of the color
greenThe green component of the color
blueThe blue component of the color
Returns
An opaque uint32_t value.