Demonstration on bitmap blit function.
#define BJ_AUTOMAIN_CALLBACKS
#include <banjo/main.h>
#define WINDOW_W 800
#define WINDOW_H 600
int bj_app_begin(void** user_data, int argc, char* argv[]) {
(void)user_data; (void)argc; (void)argv;
bj_bitmap_set_clear_color(bmp_rendering, bj_bitmap_pixel_value(bmp_rendering, 0xFF, 0x00, 0x00));
bj_bitmap_clear(bmp_rendering);
bj_bitmap_blit(bmp_greenland_grid_velo_762_1309, &(
bj_rect){.x = 0, .y = 0, .w = 762, .h = 1309}, bmp_rendering, & (
bj_rect){.x = 20, .y = 0});
bj_bitmap_blit(bmp_blackbuck_512_512, &(
bj_rect){.x = 100, .y = 100, .w = 512, .h = 512}, bmp_rendering, & (
bj_rect){.x = 100, .y = 200});
bj_bitmap_blit(bmp_snail_256_256, &(
bj_rect){.x = 0, .y = 0, .w = 256, .h = 256}, bmp_rendering, & (
bj_rect){.x = 500, .y = 130});
return bj_callback_exit_error;
}
window =
bj_window_new(
"Blitmap Blit", 0, 0, WINDOW_W, WINDOW_H, 0);
return bj_callback_continue;
}
int bj_app_iterate(void* user_data) {
(void)user_data;
? bj_callback_exit_success
: bj_callback_continue;
}
int bj_app_end(void* user_data, int status) {
(void)user_data;
return status;
}
Header file for Bitmap type.
void bj_bitmap_del(bj_bitmap *p_bitmap)
Deletes a bj_bitmap object and releases associated memory.
bj_bitmap * bj_bitmap_new(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:22
bj_bitmap * bj_bitmap_new_from_file(const char *p_path, bj_error **p_error)
Creates a new bitmap by loading from a file.
uint32_t code
Error code.
Definition error.h:132
char message[BJ_ERROR_MESSAGE_MAX_LEN+1]
Optional error description.
Definition error.h:133
Error structure.
Definition error.h:131
#define bj_err(...)
Log a message using the BJ_LOG_ERROR level.
Definition log.h:131
@ BJ_PIXEL_MODE_BGR24
24bpp BGR
Definition pixel.h:25
struct bj_rect_t bj_rect
Typedef for bj_rect_t.
Definition rect.h:15
void bj_end(bj_error **p_error)
De-initializes the system.
bj_bool bj_begin(bj_error **p_error)
Initializes the system.
void bj_sleep(int milliseconds)
Suspends the current thread for a specified duration.
bj_window * bj_window_new(const char *p_title, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint8_t flags)
Create a new bj_window with the specified attributes.
bj_bool bj_window_should_close(bj_window *p_window)
Get the close flag state of a window.
struct bj_window_t bj_window
Opaque typedef for the window type.
Definition window.h:18
bj_bitmap * bj_window_get_framebuffer(bj_window *p_window, bj_error **p_error)
Return the framebuffer attached to the window.
void bj_close_on_escape(bj_window *, bj_event_action, bj_key, int)
An event call back for closing the window when escape key is pressed.
void bj_poll_events(void)
Polls all pending events and dispatch them to callbacks.
void bj_window_del(bj_window *p_window)
Deletes a bj_window object and releases associated memory.
void bj_window_update_framebuffer(bj_window *p_window)
Copy window's framebuffer onto screen.
bj_window_key_event_t bj_window_set_key_event(bj_window *p_window, bj_window_key_event_t p_callback)
Set the callback for key events.
Logging utility functions.
All memory-related functions, including custom allocators.
Header file for system interactions.
Header file for time manipulation.
Header file for bj_window type.