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
60struct bj_bitmap;
61
68 void
69);
70
88 size_t width,
89 size_t height,
90 enum bj_pixel_mode mode,
91 size_t stride
92);
93
100 struct bj_bitmap* bitmap
101);
102
170 const char* path,
171 struct bj_error** error
172);
173
174
209 void* pixels,
210 size_t width,
211 size_t height,
212 enum bj_pixel_mode mode,
213 size_t stride
214);
215
236 const struct bj_bitmap* bitmap
237);
238
268 const struct bj_bitmap* bitmap,
269 enum bj_pixel_mode mode
270);
271
291 struct bj_bitmap* bitmap,
292 void* pixels,
293 size_t width,
294 size_t height,
295 enum bj_pixel_mode mode,
296 size_t stride
297);
298
300 struct bj_bitmap* bitmap,
301 void* pixels,
302 size_t width,
303 size_t height,
304 enum bj_pixel_mode mode,
305 size_t stride
306);
307
308
315 struct bj_bitmap* bitmap
316);
317
325 struct bj_bitmap* bitmap
326);
327
335 const struct bj_bitmap* bitmap
336);
337
345 const struct bj_bitmap* bitmap
346);
347
355 struct bj_bitmap* bitmap
356);
357
365 struct bj_bitmap* bitmap
366);
367
380 const struct bj_bitmap* bitmap,
381 size_t x,
382 size_t y,
383 uint8_t* red,
384 uint8_t* green,
385 uint8_t* blue
386);
387
399 struct bj_bitmap* bitmap,
400 uint8_t red,
401 uint8_t green,
402 uint8_t blue
403);
404
414 struct bj_bitmap* bitmap,
415 size_t x,
416 size_t y,
417 uint32_t value
418);
419
430 struct bj_bitmap* bitmap
431);
432
444 struct bj_bitmap* bitmap,
445 bj_bool enabled,
446 uint32_t key_value
447);
448
466 const struct bj_bitmap* bitmap,
467 size_t x,
468 size_t y
469);
470
478 struct bj_bitmap* bitmap,
479 uint32_t clear_color
480);
481
516 const struct bj_bitmap* src, const struct bj_rect* src_area,
517 struct bj_bitmap* dst, const struct bj_rect* dst_area,
518 enum bj_blit_op op);
519
544 const struct bj_bitmap* src, const struct bj_rect* src_area,
545 struct bj_bitmap* dst, const struct bj_rect* dst_area,
546 enum bj_blit_op op);
547
571
605 const struct bj_bitmap* mask,
606 const struct bj_rect* mask_area, /* NULL = full mask */
607 struct bj_bitmap* dst,
608 const struct bj_rect* dst_area, /* NULL = place at {0,0} w/ mask_area size */
609 uint32_t fg_native, /* dst-native packed color */
610 uint32_t bg_native, /* dst-native packed color */
611 bj_mask_bg_mode mode
612);
613
640 const struct bj_bitmap* mask,
641 const struct bj_rect* mask_area, /* NULL = full mask */
642 struct bj_bitmap* dst,
643 const struct bj_rect* dst_area, /* NULL = fill entire dst */
644 uint32_t fg_native,
645 uint32_t bg_native,
646 bj_mask_bg_mode mode
647);
648
683 struct bj_bitmap* dst,
684 int x,
685 int y,
686 unsigned height,
687 uint32_t fg_native,
688 const char* text
689);
690
713 struct bj_bitmap* bitmap,
714 int x,
715 int y,
716 unsigned height,
717 uint32_t fg_native,
718 const char* fmt,
719 ...
720);
721
776 struct bj_bitmap* dst,
777 int x,
778 int y,
779 unsigned height,
780 uint32_t fg_native,
781 uint32_t bg_native,
782 bj_mask_bg_mode mode, /* TRANSPARENT / OPAQUE / REV_TRANSPARENT */
783 const char* text
784);
785
786#endif
General-purpose definitions for Banjo API.
Recoverable error handling.
void bj_clear_bitmap(struct bj_bitmap *bitmap)
Fills the entire bitmap with the clear color.
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)
Masked blit with stretching (nearest neighbor).
void bj_assign_bitmap(struct bj_bitmap *bitmap, void *pixels, size_t width, size_t height, enum bj_pixel_mode mode, size_t stride)
struct bj_bitmap * bj_allocate_bitmap(void)
Allocate a new bitmap object.
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)
Stretched bitmap blitting (nearest neighbor).
bj_mask_bg_mode
Mask background mode for masked blits (glyph/text rendering).
Definition bitmap.h:566
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)
Get the underlying pixels data for direct access.
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)
Bitmap blitting operation from a source to a destination bitmap.
size_t bj_bitmap_height(const struct bj_bitmap *bitmap)
Get the height of the given bitmap.
size_t bj_bitmap_stride(struct bj_bitmap *bitmap)
Get the number of bytes in a row of pixel data, including the padding.
void bj_reset_bitmap(struct bj_bitmap *bitmap)
Resets a struct bj_bitmap object making it ready for a new init or free.
void bj_set_bitmap_clear_color(struct bj_bitmap *bitmap, uint32_t clear_color)
Sets the color used for clearing the bitmap.
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)
Gets the RGB value of a pixel given its 32-bits representation.
uint32_t bj_make_bitmap_pixel(struct bj_bitmap *bitmap, uint8_t red, uint8_t green, uint8_t blue)
Returns an opaque value representing a pixel color, given its RGB composition.
bj_blit_op
Raster operation (ROP) to apply during blitting.
Definition bitmap.h:48
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)
Masked blit (non-stretched).
size_t bj_bitmap_width(const struct bj_bitmap *bitmap)
Get the width of the given bitmap.
void bj_blit_text(struct 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.
void bj_draw_textf(struct bj_bitmap *bitmap, int x, int y, unsigned height, uint32_t fg_native, const char *fmt,...)
Prints formatted text into a bitmap, similar to printf.
void bj_draw_text(struct 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.
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)
Initializes a new struct bj_bitmap with the specified width and height.
void bj_set_bitmap_colorkey(struct bj_bitmap *bitmap, bj_bool enabled, uint32_t key_value)
Enables or disables color key transparency for blitting.
int bj_bitmap_mode(struct bj_bitmap *bitmap)
Get the pixel mode of the given bitmap.
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.
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 color at given coordinate.
uint32_t bj_bitmap_pixel(const struct bj_bitmap *bitmap, size_t x, size_t y)
Gets the color of a bitmap pixel, given its coordinates.
void bj_destroy_bitmap(struct bj_bitmap *bitmap)
Deletes a struct bj_bitmap object and releases associated memory.
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.
Definition bitmap.h:567
@ BJ_MASK_BG_OPAQUE
Opaque band: mix(background, foreground, mask)
Definition bitmap.h:568
@ BJ_MASK_BG_REV_TRANSPARENT
Carved: mix(destination, background, 1-mask)
Definition bitmap.h:569
@ 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:155
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:249
struct bj_bitmap bj_bitmap
Definition api.h:331
Error structure.
Definition error.h:131
Represents a rectangle with position and dimensions.
Definition rect.h:19
bj_pixel_mode
Representation of a pixel encoding.
Definition pixel.h:16
Header file for general pixel manipulation facilities.
Defines the struct bj_rect struct representing a rectangle with position and dimensions.
Header file for struct bj_stream struct and related functions.