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#ifndef BJ_NO_TYPEDEF
58#endif
59
77
78
79
81struct bj_bitmap;
82
89 void
90);
91
109 size_t width,
110 size_t height,
111 enum bj_pixel_mode mode,
112 size_t stride
113);
114
121 struct bj_bitmap* bitmap
122);
123
191 const char* path,
192 struct bj_error** error
193);
194
195
230 void* pixels,
231 size_t width,
232 size_t height,
233 enum bj_pixel_mode mode,
234 size_t stride
235);
236
257 const struct bj_bitmap* bitmap
258);
259
289 const struct bj_bitmap* bitmap,
290 enum bj_pixel_mode mode
291);
292
312 struct bj_bitmap* bitmap,
313 void* pixels,
314 size_t width,
315 size_t height,
316 enum bj_pixel_mode mode,
317 size_t stride
318);
319
321 struct bj_bitmap* bitmap,
322 void* pixels,
323 size_t width,
324 size_t height,
325 enum bj_pixel_mode mode,
326 size_t stride
327);
328
329
336 struct bj_bitmap* bitmap
337);
338
346 struct bj_bitmap* bitmap
347);
348
356 const struct bj_bitmap* bitmap
357);
358
366 const struct bj_bitmap* bitmap
367);
368
376 struct bj_bitmap* bitmap
377);
378
386 struct bj_bitmap* bitmap
387);
388
401 const struct bj_bitmap* bitmap,
402 size_t x,
403 size_t y,
404 uint8_t* red,
405 uint8_t* green,
406 uint8_t* blue
407);
408
420 struct bj_bitmap* bitmap,
421 uint8_t red,
422 uint8_t green,
423 uint8_t blue
424);
425
435 struct bj_bitmap* bitmap,
436 size_t x,
437 size_t y,
438 uint32_t value
439);
440
452 struct bj_bitmap* bitmap
453);
454
492 struct bj_bitmap* bitmap,
493 uint32_t color,
494 uint8_t roles
495);
496
515 struct bj_bitmap* bitmap,
516 bj_bool enabled
517);
518
536 const struct bj_bitmap* bitmap,
537 size_t x,
538 size_t y
539);
540
541
576 const struct bj_bitmap* src, const struct bj_rect* src_area,
577 struct bj_bitmap* dst, const struct bj_rect* dst_area,
578 enum bj_blit_op op);
579
604 const struct bj_bitmap* src, const struct bj_rect* src_area,
605 struct bj_bitmap* dst, const struct bj_rect* dst_area,
606 enum bj_blit_op op);
607
631
665 const struct bj_bitmap* mask,
666 const struct bj_rect* mask_area, /* NULL = full mask */
667 struct bj_bitmap* dst,
668 const struct bj_rect* dst_area, /* NULL = place at {0,0} w/ mask_area size */
669 uint32_t fg_native, /* dst-native packed color */
670 uint32_t bg_native, /* dst-native packed color */
671 bj_mask_bg_mode mode
672);
673
700 const struct bj_bitmap* mask,
701 const struct bj_rect* mask_area, /* NULL = full mask */
702 struct bj_bitmap* dst,
703 const struct bj_rect* dst_area, /* NULL = fill entire dst */
704 uint32_t fg_native,
705 uint32_t bg_native,
706 bj_mask_bg_mode mode
707);
708
743 struct bj_bitmap* dst,
744 int x,
745 int y,
746 unsigned height,
747 uint32_t fg_native,
748 const char* text
749);
750
773 struct bj_bitmap* bitmap,
774 int x,
775 int y,
776 unsigned height,
777 uint32_t fg_native,
778 const char* fmt,
779 ...
780);
781
836 struct bj_bitmap* dst,
837 int x,
838 int y,
839 unsigned height,
840 uint32_t fg_native,
841 uint32_t bg_native,
842 bj_mask_bg_mode mode, /* TRANSPARENT / OPAQUE / REV_TRANSPARENT */
843 const char* text
844);
845
846#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:626
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_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).
bj_bitmap_color_role
Color roles for bitmaps.
Definition bitmap.h:73
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.
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.
void bj_set_bitmap_color(struct bj_bitmap *bitmap, uint32_t color, uint8_t roles)
Sets one or more color properties of a bitmap.
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_enable_colorkey(struct bj_bitmap *bitmap, bj_bool enabled)
Enables or disables color key transparency for blitting.
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:627
@ BJ_MASK_BG_OPAQUE
Opaque band: mix(background, foreground, mask)
Definition bitmap.h:628
@ BJ_MASK_BG_REV_TRANSPARENT
Carved: mix(destination, background, 1-mask)
Definition bitmap.h:629
@ 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
@ BJ_BITMAP_CLEAR_COLOR
Clear/fill color for bj_clear_bitmap()
Definition bitmap.h:74
@ BJ_BITMAP_COLORKEY
Transparency key for blitting (auto-enables)
Definition bitmap.h:75
struct bj_error bj_error
Definition api.h:275
#define BANJO_EXPORT
Definition api.h:106
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:200
struct bj_bitmap bj_bitmap
Definition api.h:270
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.