From 39e25c13e5f448e3a2cb64fa875ac401d2cfaa99 Mon Sep 17 00:00:00 2001 From: Milang Date: Wed, 23 Oct 2019 15:32:40 +0200 Subject: [PATCH] Complete bitmap doc --- include/fxengine/model/bitmap.h | 17 ++++++-------- include/fxengine/model/bitmap.md | 40 ++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/include/fxengine/model/bitmap.h b/include/fxengine/model/bitmap.h index ad0cd06..e66973a 100644 --- a/include/fxengine/model/bitmap.h +++ b/include/fxengine/model/bitmap.h @@ -20,33 +20,30 @@ typedef struct fe_bitmap } fe_bitmap; -/* fe_bitmap_new_rich() +/* fe_bitmap_new() creates a new bitmap in the ram with this function, the bmp is dynamic only, but there is still a way tou create it staticly : you create a dynamic bmp you create a static bmp you do a memcpy*/ -fe_bitmap_rich* fe_bitmap_new_rich( +fe_bitmap* fe_bitmap_new( uint32_t size_px_x, uint32_t size_px_y, // bitmap size uint32_t* color, bool copy_color, // color table address and type (static | dynamic) uint32_t *layout, bool copy_layout // layout table address and type (static | dynamic) ); -/** - * @brief delete a rich bitmap created with bitmap_new_rich() - * - * @param txtr The bitmap to delete - */ -void fe_bitmap_delete_rich(fe_bitmap_rich * txtr); +/* fe_bitmap_del() +deletes the bitmap from the ram */ +void fe_bitmap_del(fe_bitmap * txtr); /* fe_bitmap_get_pixel() returns the color of a pixel in the gint's type*/ -uint8_t fe_bitmap_get_pixel_r(const fe_bitmap_rich * txtr, uint32_t x, uint32_t y); +uint8_t fe_bitmap_get_pixel(const fe_bitmap * txtr, uint32_t x, uint32_t y); /* fe_bitmap_display_pixel() display a specific rich bitmap pixel on the screen (on vram) */ -void fe_bitmap_display_pixel_r(const fe_bitmap_rich * txtr, uint32_t txtr_x, uint32_t txtr_y, uint32_t x, uint32_t y); +void fe_bitmap_display_pixel(const fe_bitmap * txtr, uint32_t txtr_x, uint32_t txtr_y, uint32_t x, uint32_t y); #endif diff --git a/include/fxengine/model/bitmap.md b/include/fxengine/model/bitmap.md index f2e7890..ee7e977 100644 --- a/include/fxengine/model/bitmap.md +++ b/include/fxengine/model/bitmap.md @@ -1,4 +1,6 @@ -# Bitmap data +# Fxengine::Bitmap +This is part of the [fxengine](/Milang/fxengine) project. +This file refers to [bitmap.h](/Milang/fxengine/include/fxengine/model/bitmap.h) header. ```c #include ``` @@ -20,7 +22,37 @@ typedef struct fe_bitmap uint16_t size_o_y; } fe_bitmap; ``` -Here are the most used parameters : -- `size_px_x` and `size_px_y` are the bitmap's height and width, in pixels. +Here are the most used parameters, the others are used internally by the machine, so they do not need to be initialized. +### Size +`size_px_x` and `size_px_y` are the bitmap's height and width, in pixels. +### Color and layout encoding - `*color` is a pointer to a monochrome bitmap. -The format is the following : one bit is on pixel => 1 means black, 0 means white. \ No newline at end of file +The format is the following : one bit per pixel: 1 = black, 0 = white. +- `*layout` is a pointer to a layout for the previous bitmap. +It is one bit per pixel too, and then, 1=visible, 0=invisible. + +## Use +### Create +It is not recommended to create a bitmap as this : +```c +fe_bitmap bmp +{...}; +``` +Please use the function +```c +fe_bitmap_rich* fe_bitmap_new( + uint32_t size_px_x, uint32_t size_px_y, // bitmap size + uint32_t* color, bool copy_color, // color table address and type (static | dynamic) + uint32_t *layout, bool copy_layout // layout table address and type (static | dynamic) + ); +``` +The `bool copy_<...>` lets you choose: +- if the bitmap header takes data from the pointer you have given. +- if the bitmap header needs to copy data itself. + +### Delete +The bitmap is dynamically allocated, so it should be deleted by using `free()` method. However, it contains some complex data, which is itself dynamically allocated, so you need to call that method: `fe_bitmap_del()`. +The only argument to pass is the bitmap's address. + +### Display +Basically, you can display the bitmap with `` \ No newline at end of file