395 size_t width,
size_t height,
enum bj_pixel_mode mode,
size_t stride);
401 size_t width,
size_t height,
enum bj_pixel_mode mode,
size_t stride);
483 uint8_t* red, uint8_t* green, uint8_t* blue);
506 uint8_t red, uint8_t green, uint8_t blue);
770 const struct bj_rect* mask_area,
772 const struct bj_rect* dst_area,
813 const struct bj_rect* mask_area,
815 const struct bj_rect* dst_area,
General-purpose definitions for Banjo API.
Recoverable error handling.
void bj_clear_bitmap(struct bj_bitmap *bitmap)
Fills the entire bitmap with the clear colour.
void bj_set_bitmap_colorkey(struct bj_bitmap *bitmap, uint32_t color)
Set the transparent colour used when this bitmap is a blit source, and enable colour keying.
bj_bool bj_blit_mask_stretched(const struct bj_bitmap *mask, const struct bj_rect *mask_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
size_t bj_bitmap_stride(const struct bj_bitmap *bitmap)
Get the number of bytes in a row of pixel data, including the padding.
unsigned bj_measure_text(const char *text, unsigned height)
Measures the pixel width of a text string at a given height.
struct bj_bitmap * bj_create_bitmap_from_stream(struct bj_stream *stream, struct bj_error **error)
Loads a BMP image from a stream into a new bitmap.
void bj_assign_bitmap(struct bj_bitmap *bitmap, void *pixels, size_t width, size_t height, enum bj_pixel_mode mode, size_t stride)
int bj_bitmap_mode(const struct bj_bitmap *bitmap)
Get the pixel mode of the given bitmap.
bj_bool bj_blit_bitmap(const struct bj_bitmap *src, const struct bj_rect *src_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, enum bj_blit_op op)
Bitmap blitting operation from a source to a destination bitmap.
struct bj_bitmap * bj_allocate_bitmap(void)
bj_bool bj_blit_stretched(const struct bj_bitmap *src, const struct bj_rect *src_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, enum bj_blit_op op)
bj_bool bj_blit_bitmap_stretched(const struct bj_bitmap *src, const struct bj_rect *src_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, enum bj_blit_op op)
Stretched bitmap blitting (nearest neighbor).
bj_mask_bg_mode
Mask background mode for masked blits (glyph/text rendering).
struct bj_bitmap * bj_create_bitmap_from_file(const char *path, struct bj_error **error)
Creates a new bitmap by loading from a file.
void * bj_bitmap_pixels(struct bj_bitmap *bitmap)
void bj_draw_textf(struct bj_bitmap *dst, unsigned height, struct bj_rect area, bj_text_halign halign, bj_text_valign valign, uint32_t fg_native, const char *fmt,...)
Prints formatted text into a bitmap, similar to printf.
bj_bool bj_blit(const struct bj_bitmap *src, const struct bj_rect *src_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, enum bj_blit_op op)
size_t bj_bitmap_height(const struct bj_bitmap *bitmap)
Get the height of the given bitmap.
void bj_set_bitmap_clear_color(struct bj_bitmap *bitmap, uint32_t color)
Set the colour bj_clear_bitmap fills with.
void bj_reset_bitmap(struct bj_bitmap *bitmap)
void bj_disable_bitmap_colorkey(struct bj_bitmap *bitmap)
Turn colour keying off for this bitmap, keeping the key colour.
void bj_enable_bitmap_colorkey(struct bj_bitmap *bitmap)
Turn colour keying on for this bitmap (as a blit source).
void bj_make_bitmap_rgb(const struct bj_bitmap *bitmap, size_t x, size_t y, uint8_t *red, uint8_t *green, uint8_t *blue)
void * bj_bitmap_pixel_data(struct bj_bitmap *bitmap)
Reach the bitmap's raw pixel buffer for direct access.
uint32_t bj_make_bitmap_pixel(struct bj_bitmap *bitmap, uint8_t red, uint8_t green, uint8_t blue)
bj_blit_op
Raster operation (ROP) to apply during blitting.
uint32_t bj_pack_bitmap_rgb(struct bj_bitmap *bitmap, uint8_t red, uint8_t green, uint8_t blue)
Pack an (R, G, B) triple into the bitmap's native pixel format.
struct bj_bitmap * bj_convert_bitmap(const struct bj_bitmap *bitmap, enum bj_pixel_mode mode)
Creates a new struct bj_bitmap by converting bitmap.
bj_bool bj_blit_mask(const struct bj_bitmap *mask, const struct bj_rect *mask_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
size_t bj_bitmap_width(const struct bj_bitmap *bitmap)
Get the width of the given bitmap.
struct bj_bitmap * bj_init_bitmap(struct bj_bitmap *bitmap, void *pixels, size_t width, size_t height, enum bj_pixel_mode mode, size_t stride)
void bj_bitmap_pixel_rgb(const struct bj_bitmap *bitmap, size_t x, size_t y, uint8_t *red, uint8_t *green, uint8_t *blue)
Read the pixel at (x, y) as separate R, G, B components.
struct bj_bitmap * bj_create_bitmap(size_t width, size_t height, enum bj_pixel_mode mode, size_t stride)
Creates a new struct bj_bitmap with the specified width and height.
bj_text_halign
Horizontal alignment for text rendering.
struct bj_bitmap * bj_create_bitmap_from_pixels(void *pixels, size_t width, size_t height, enum bj_pixel_mode mode, size_t stride)
Creates a new struct bj_bitmap with the specified width and height.
void bj_put_pixel(struct bj_bitmap *bitmap, size_t x, size_t y, uint32_t value)
Change the pixel colour at given coordinate.
void bj_draw_text(struct bj_bitmap *dst, unsigned height, struct bj_rect area, bj_text_halign halign, bj_text_valign valign, uint32_t fg_native, const char *text)
Prints text in a foreground colour over a transparent background.
void bj_set_bitmap_color(struct bj_bitmap *bitmap, uint32_t color, uint8_t roles)
uint32_t bj_bitmap_pixel(const struct bj_bitmap *bitmap, size_t x, size_t y)
Gets the colour of a bitmap pixel, given its coordinates.
bj_bool bj_blit_bitmap_mask(const struct bj_bitmap *mask, const struct bj_rect *mask_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
Masked blit (non-stretched).
void bj_enable_colorkey(struct bj_bitmap *bitmap, bj_bool enabled)
void bj_destroy_bitmap(struct bj_bitmap *bitmap)
Deletes a struct bj_bitmap object and releases associated memory.
void bj_blit_text(struct bj_bitmap *dst, unsigned height, struct bj_rect area, bj_text_halign halign, bj_text_valign valign, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode, const char *text)
Prints text with explicit foreground/background and background mode.
bj_text_valign
Vertical alignment for text rendering.
bj_bool bj_blit_bitmap_mask_stretched(const struct bj_bitmap *mask, const struct bj_rect *mask_area, struct bj_bitmap *dst, const struct bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
Masked blit with stretching (nearest neighbor).
struct bj_bitmap * bj_copy_bitmap(const struct bj_bitmap *bitmap)
Creates a new struct bj_bitmap by copying bitmap.
@ BJ_MASK_BG_TRANSPARENT
Foreground over destination where mask>0.
@ BJ_MASK_BG_OPAQUE
Opaque band: mix(background, foreground, mask)
@ BJ_MASK_BG_REV_TRANSPARENT
Carved: mix(destination, background, 1-mask)
@ BJ_BLIT_OP_OR
Bitwise OR.
@ BJ_BLIT_OP_COPY
Copy source to destination (fast path when formats match)
@ BJ_BLIT_OP_AND
Bitwise AND.
@ BJ_BLIT_OP_ADD_SAT
Per-channel saturated add (clamped to 255)
@ BJ_BLIT_OP_XOR
Bitwise XOR (channel-wise for >8bpp)
@ BJ_BLIT_OP_SUB_SAT
Per-channel saturated subtract (clamped to 0)
@ BJ_BITMAP_CLEAR_COLOR
Clear/fill colour for bj_clear_bitmap()
@ BJ_BITMAP_COLORKEY
Transparency key for blitting (auto-enables)
@ BJ_TEXT_HALIGN_RIGHT
Align text to the right edge of the area.
@ BJ_TEXT_HALIGN_LEFT
Align text to the left edge of the area.
@ BJ_TEXT_HALIGN_CENTER
Center text horizontally within the area.
@ BJ_TEXT_VALIGN_BOTTOM
Align text to the bottom edge of the area.
@ BJ_TEXT_VALIGN_CENTER
Center text vertically within the area.
@ BJ_TEXT_VALIGN_TOP
Align text to the top edge of the area.
struct bj_stream bj_stream
uint32_t bj_bool
Boolean type used throughout the Banjo API.
struct bj_bitmap bj_bitmap
Axis-aligned rectangle: a top-left corner plus a width and height.
bj_pixel_mode
Representation of a pixel encoding.
Header file for general pixel manipulation facilities.
Axis-aligned rectangle in pixel coordinates.
Header file for struct bj_stream struct and related functions.