Banjo API 1.0.0-rc.2
Low-level C99 game development API
Loading...
Searching...
No Matches
bitmap.h
Go to the documentation of this file.
1
74#ifndef BJ_BITMAP_H
75#define BJ_BITMAP_H
76#include <banjo/api.h>
77#include <banjo/error.h>
78#include <banjo/pixel.h>
79#include <banjo/rect.h>
80#include <banjo/stream.h>
81
100#ifndef BJ_NO_TYPEDEF
102#endif
103
121
122
123
125struct bj_bitmap;
126
133 void
134);
135
153 size_t width,
154 size_t height,
155 enum bj_pixel_mode mode,
156 size_t stride
157);
158
165 struct bj_bitmap* bitmap
166);
167
235 const char* path,
236 struct bj_error** error
237);
238
239
274 void* pixels,
275 size_t width,
276 size_t height,
277 enum bj_pixel_mode mode,
278 size_t stride
279);
280
301 const struct bj_bitmap* bitmap
302);
303
333 const struct bj_bitmap* bitmap,
334 enum bj_pixel_mode mode
335);
336
356 struct bj_bitmap* bitmap,
357 void* pixels,
358 size_t width,
359 size_t height,
360 enum bj_pixel_mode mode,
361 size_t stride
362);
363
365 struct bj_bitmap* bitmap,
366 void* pixels,
367 size_t width,
368 size_t height,
369 enum bj_pixel_mode mode,
370 size_t stride
371);
372
373
380 struct bj_bitmap* bitmap
381);
382
390 struct bj_bitmap* bitmap
391);
392
400 const struct bj_bitmap* bitmap
401);
402
410 const struct bj_bitmap* bitmap
411);
412
420 struct bj_bitmap* bitmap
421);
422
430 struct bj_bitmap* bitmap
431);
432
445 const struct bj_bitmap* bitmap,
446 size_t x,
447 size_t y,
448 uint8_t* red,
449 uint8_t* green,
450 uint8_t* blue
451);
452
464 struct bj_bitmap* bitmap,
465 uint8_t red,
466 uint8_t green,
467 uint8_t blue
468);
469
479 struct bj_bitmap* bitmap,
480 size_t x,
481 size_t y,
482 uint32_t value
483);
484
496 struct bj_bitmap* bitmap
497);
498
536 struct bj_bitmap* bitmap,
537 uint32_t color,
538 uint8_t roles
539);
540
559 struct bj_bitmap* bitmap,
560 bj_bool enabled
561);
562
580 const struct bj_bitmap* bitmap,
581 size_t x,
582 size_t y
583);
584
585
620 const struct bj_bitmap* src, const struct bj_rect* src_area,
621 struct bj_bitmap* dst, const struct bj_rect* dst_area,
622 enum bj_blit_op op);
623
648 const struct bj_bitmap* src, const struct bj_rect* src_area,
649 struct bj_bitmap* dst, const struct bj_rect* dst_area,
650 enum bj_blit_op op);
651
675
709 const struct bj_bitmap* mask,
710 const struct bj_rect* mask_area, /* NULL = full mask */
711 struct bj_bitmap* dst,
712 const struct bj_rect* dst_area, /* NULL = place at {0,0} w/ mask_area size */
713 uint32_t fg_native, /* dst-native packed colour */
714 uint32_t bg_native, /* dst-native packed colour */
715 bj_mask_bg_mode mode
716);
717
744 const struct bj_bitmap* mask,
745 const struct bj_rect* mask_area, /* NULL = full mask */
746 struct bj_bitmap* dst,
747 const struct bj_rect* dst_area, /* NULL = fill entire dst */
748 uint32_t fg_native,
749 uint32_t bg_native,
750 bj_mask_bg_mode mode
751);
752
787 struct bj_bitmap* dst,
788 int x,
789 int y,
790 unsigned height,
791 uint32_t fg_native,
792 const char* text
793);
794
817 struct bj_bitmap* bitmap,
818 int x,
819 int y,
820 unsigned height,
821 uint32_t fg_native,
822 const char* fmt,
823 ...
824);
825
880 struct bj_bitmap* dst,
881 int x,
882 int y,
883 unsigned height,
884 uint32_t fg_native,
885 uint32_t bg_native,
886 bj_mask_bg_mode mode, /* TRANSPARENT / OPAQUE / REV_TRANSPARENT */
887 const char* text
888);
889
890#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 colour.
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:670
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 colour, given its RGB composition.
bj_blit_op
Raster operation (ROP) to apply during blitting.
Definition bitmap.h:92
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
Colour roles for bitmaps.
Definition bitmap.h:117
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 colour 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)
Initialises 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 colour at given coordinate.
void bj_set_bitmap_color(struct bj_bitmap *bitmap, uint32_t color, uint8_t roles)
Sets one or more colour properties of a bitmap.
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.
void bj_enable_colorkey(struct bj_bitmap *bitmap, bj_bool enabled)
Enables or disables colour 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:671
@ BJ_MASK_BG_OPAQUE
Opaque band: mix(background, foreground, mask)
Definition bitmap.h:672
@ BJ_MASK_BG_REV_TRANSPARENT
Carved: mix(destination, background, 1-mask)
Definition bitmap.h:673
@ BJ_BLIT_OP_OR
Bitwise OR.
Definition bitmap.h:95
@ BJ_BLIT_OP_COPY
Copy source to destination (fast path when formats match)
Definition bitmap.h:93
@ BJ_BLIT_OP_AND
Bitwise AND.
Definition bitmap.h:96
@ BJ_BLIT_OP_ADD_SAT
Per-channel saturated add (clamped to 255)
Definition bitmap.h:97
@ BJ_BLIT_OP_XOR
Bitwise XOR (channel-wise for >8bpp)
Definition bitmap.h:94
@ BJ_BLIT_OP_SUB_SAT
Per-channel saturated subtract (clamped to 0)
Definition bitmap.h:98
@ BJ_BITMAP_CLEAR_COLOR
Clear/fill colour for bj_clear_bitmap()
Definition bitmap.h:118
@ BJ_BITMAP_COLORKEY
Transparency key for blitting (auto-enables)
Definition bitmap.h:119
struct bj_error bj_error
Definition api.h:333
#define BANJO_EXPORT
Definition api.h:163
uint32_t bj_bool
Boolean type used throughout the Banjo API.
Definition api.h:257
struct bj_bitmap bj_bitmap
Definition api.h:328
Axis-aligned rectangle: a top-left corner plus a width and height.
Definition rect.h:33
bj_pixel_mode
Representation of a pixel encoding.
Definition pixel.h:86
Header file for general pixel manipulation facilities.
Axis-aligned rectangle in pixel coordinates.
Header file for struct bj_stream struct and related functions.