Banjo API 0.0.1
C99 game development API
Loading...
Searching...
No Matches
bitmap.h
Go to the documentation of this file.
1
30#ifndef BJ_BITMAP_H
31#define BJ_BITMAP_H
32#include <banjo/api.h>
33#include <banjo/error.h>
34#include <banjo/pixel.h>
35#include <banjo/rect.h>
36#include <banjo/stream.h>
37
56
57
58
60typedef struct bj_bitmap_t bj_bitmap;
61
68 void
69);
70
88 size_t width,
89 size_t height,
90 bj_pixel_mode mode,
91 size_t stride
92);
93
100 bj_bitmap* p_bitmap
101);
102
170 const char* p_path,
171 bj_error** p_error
172);
173
174
209 void* p_pixels,
210 size_t width,
211 size_t height,
212 bj_pixel_mode mode,
213 size_t stride
214);
215
236 const bj_bitmap* p_bitmap
237);
238
268 const bj_bitmap* p_bitmap,
269 bj_pixel_mode mode
270);
271
291 bj_bitmap* p_bitmap,
292 void* p_pixels,
293 size_t width,
294 size_t height,
295 bj_pixel_mode mode,
296 size_t stride
297);
298
305 bj_bitmap* p_bitmap
306);
307
315 bj_bitmap* p_bitmap
316);
317
325 const bj_bitmap* p_bitmap
326);
327
335 const bj_bitmap* p_bitmap
336);
337
345 bj_bitmap* p_bitmap
346);
347
355 bj_bitmap* p_bitmap
356);
357
370 const bj_bitmap* p_bitmap,
371 size_t x,
372 size_t y,
373 uint8_t* p_red,
374 uint8_t* p_green,
375 uint8_t* p_blue
376);
377
389 bj_bitmap* p_bitmap,
390 uint8_t red,
391 uint8_t green,
392 uint8_t blue
393);
394
404 bj_bitmap* p_bitmap,
405 size_t x,
406 size_t y,
407 uint32_t value
408);
409
420 bj_bitmap* p_bitmap
421);
422
434 bj_bitmap* p_bitmap,
435 bj_bool enabled,
436 uint32_t key_value
437);
438
456 const bj_bitmap* p_bitmap,
457 size_t x,
458 size_t y
459);
460
468 bj_bitmap* p_bitmap,
469 uint32_t clear_color
470);
471
506 const bj_bitmap* src, const bj_rect* src_area,
507 bj_bitmap* dst, const bj_rect* dst_area,
508 bj_blit_op op);
509
534 const bj_bitmap* src, const bj_rect* src_area,
535 bj_bitmap* dst, const bj_rect* dst_area,
536 bj_blit_op op);
537
561
595 const bj_bitmap* mask,
596 const bj_rect* mask_area, /* NULL = full mask */
597 bj_bitmap* dst,
598 const bj_rect* dst_area, /* NULL = place at {0,0} w/ mask_area size */
599 uint32_t fg_native, /* dst-native packed color */
600 uint32_t bg_native, /* dst-native packed color */
601 bj_mask_bg_mode mode
602);
603
630 const bj_bitmap* mask,
631 const bj_rect* mask_area, /* NULL = full mask */
632 bj_bitmap* dst,
633 const bj_rect* dst_area, /* NULL = fill entire dst */
634 uint32_t fg_native,
635 uint32_t bg_native,
636 bj_mask_bg_mode mode
637);
638
673 bj_bitmap* dst,
674 int x,
675 int y,
676 unsigned height,
677 uint32_t fg_native,
678 const char* text
679);
680
703 bj_bitmap* p_bitmap,
704 int x,
705 int y,
706 unsigned height,
707 uint32_t fg_native,
708 const char* fmt,
709 ...
710);
711
766 bj_bitmap* dst,
767 int x,
768 int y,
769 unsigned height,
770 uint32_t fg_native,
771 uint32_t bg_native,
772 bj_mask_bg_mode mode, /* TRANSPARENT / OPAQUE / REV_TRANSPARENT */
773 const char* text
774);
775
776#endif
General-purpose definitions for Banjo API.
Recoverable error handling.
bj_bool bj_blit_mask(const bj_bitmap *mask, const bj_rect *mask_area, bj_bitmap *dst, const bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
Masked blit (non-stretched).
bj_bitmap * bj_allocate_bitmap(void)
Allocate a new bitmap object.
size_t bj_bitmap_stride(bj_bitmap *p_bitmap)
Get the number of bytes in a row of pixel data, including the padding.
size_t bj_bitmap_width(const bj_bitmap *p_bitmap)
Get the width of the given bitmap.
bj_bool bj_blit_stretched(const bj_bitmap *src, const bj_rect *src_area, bj_bitmap *dst, const bj_rect *dst_area, bj_blit_op op)
Stretched bitmap blitting (nearest neighbor).
int bj_bitmap_mode(bj_bitmap *p_bitmap)
Get the pixel mode of the given bitmap.
bj_bitmap * bj_create_bitmap_from_pixels(void *p_pixels, size_t width, size_t height, bj_pixel_mode mode, size_t stride)
Creates a new bj_bitmap with the specified width and height.
bj_bitmap * bj_init_bitmap(bj_bitmap *p_bitmap, void *p_pixels, size_t width, size_t height, bj_pixel_mode mode, size_t stride)
Initializes a new bj_bitmap with the specified width and height.
bj_bool bj_blit(const bj_bitmap *src, const bj_rect *src_area, bj_bitmap *dst, const bj_rect *dst_area, bj_blit_op op)
Bitmap blitting operation from a source to a destination bitmap.
bj_mask_bg_mode
Mask background mode for masked blits (glyph/text rendering).
Definition bitmap.h:556
void bj_reset_bitmap(bj_bitmap *p_bitmap)
Resets a bj_bitmap object making it ready for a new init or free.
void bj_blit_text(bj_bitmap *dst, int x, int y, unsigned height, 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_bitmap * bj_convert_bitmap(const bj_bitmap *p_bitmap, bj_pixel_mode mode)
Creates a new bj_bitmap by converting p_bitmap.
size_t bj_bitmap_height(const bj_bitmap *p_bitmap)
Get the height of the given bitmap.
bj_bitmap * bj_copy_bitmap(const bj_bitmap *p_bitmap)
Creates a new bj_bitmap by copying p_bitmap.
void bj_draw_text(bj_bitmap *dst, int x, int y, unsigned height, uint32_t fg_native, const char *text)
Prints text using the default foreground color and transparent background.
void * bj_bitmap_pixels(bj_bitmap *p_bitmap)
Get the underlying pixels data for direct access.
bj_blit_op
Raster operation (ROP) to apply during blitting.
Definition bitmap.h:48
void bj_make_bitmap_rgb(const bj_bitmap *p_bitmap, size_t x, size_t y, uint8_t *p_red, uint8_t *p_green, uint8_t *p_blue)
Gets the RGB value of a pixel given its 32-bits representation.
void bj_set_bitmap_colorkey(bj_bitmap *p_bitmap, bj_bool enabled, uint32_t key_value)
Enables or disables color key transparency for blitting.
uint32_t bj_make_bitmap_pixel(bj_bitmap *p_bitmap, uint8_t red, uint8_t green, uint8_t blue)
Returns an opaque value representing a pixel color, given its RGB composition.
uint32_t bj_bitmap_pixel(const bj_bitmap *p_bitmap, size_t x, size_t y)
Gets the color of a bitmap pixel, given its coordinates.
void bj_destroy_bitmap(bj_bitmap *p_bitmap)
Deletes a bj_bitmap object and releases associated memory.
void bj_set_bitmap_clear_color(bj_bitmap *p_bitmap, uint32_t clear_color)
Sets the color used for clearing the bitmap.
void bj_clear_bitmap(bj_bitmap *p_bitmap)
Fills the entire bitmap with the clear color.
bj_bitmap * bj_create_bitmap(size_t width, size_t height, bj_pixel_mode mode, size_t stride)
Creates a new bj_bitmap with the specified width and height.
struct bj_bitmap_t bj_bitmap
Typedef for the bj_bitmap struct.
Definition bitmap.h:60
void bj_put_pixel(bj_bitmap *p_bitmap, size_t x, size_t y, uint32_t value)
Change the pixel color at given coordinate.
void bj_draw_textf(bj_bitmap *p_bitmap, int x, int y, unsigned height, uint32_t fg_native, const char *fmt,...)
Prints formatted text into a bitmap, similar to printf.
bj_bitmap * bj_create_bitmap_from_file(const char *p_path, bj_error **p_error)
Creates a new bitmap by loading from a file.
bj_bool bj_blit_mask_stretched(const bj_bitmap *mask, const bj_rect *mask_area, bj_bitmap *dst, const bj_rect *dst_area, uint32_t fg_native, uint32_t bg_native, bj_mask_bg_mode mode)
Masked blit with stretching (nearest neighbor).
@ BJ_MASK_BG_TRANSPARENT
Foreground over destination where mask>0.
Definition bitmap.h:557
@ BJ_MASK_BG_OPAQUE
Opaque band: mix(background, foreground, mask)
Definition bitmap.h:558
@ BJ_MASK_BG_REV_TRANSPARENT
Carved: mix(destination, background, 1-mask)
Definition bitmap.h:559
@ BJ_BLIT_OP_OR
Bitwise OR.
Definition bitmap.h:51
@ BJ_BLIT_OP_COPY
Copy source to destination (fast path when formats match)
Definition bitmap.h:49
@ BJ_BLIT_OP_AND
Bitwise AND.
Definition bitmap.h:52
@ BJ_BLIT_OP_ADD_SAT
Per-channel saturated add (clamped to 255)
Definition bitmap.h:53
@ BJ_BLIT_OP_XOR
Bitwise XOR (channel-wise for >8bpp)
Definition bitmap.h:50
@ BJ_BLIT_OP_SUB_SAT
Per-channel saturated subtract (clamped to 0)
Definition bitmap.h:54
#define BANJO_EXPORT
Definition api.h:139
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:276
Error structure.
Definition error.h:131
struct bj_rect_t bj_rect
Typedef for bj_rect_t.
Definition rect.h:15
bj_pixel_mode
Representation of a pixel encoding.
Definition pixel.h:16
Header file for general pixel manipulation facilities.
Defines the bj_rect struct representing a rectangle with position and dimensions.
Header file for bj_stream_t struct and related functions.