fxengine/include/fxengine/model/bitmap.md

59 lines
2.0 KiB
Markdown
Raw Normal View History

2019-10-23 15:32:40 +02:00
# Fxengine::Bitmap
This is part of the [fxengine](/Milang/fxengine) project.
2019-10-23 15:34:13 +02:00
This file refers to [bitmap.h](bitmap.h) header.
```c
#include <fxengine/model/bitmap.h>
```
## What is it ?
The `fe_bitmap` data structure is a way to use pictures in fxengine. These pictures are saved with a format which is near to the `*.bmp` type.
## Detail
```c
typedef struct fe_bitmap
{
uint32_t size_px_x;
uint32_t size_px_y;
uint32_t * color;
uint32_t * layout;
bool color_dynamic;
bool layout_dynamic;
uint16_t size_o_y;
} fe_bitmap;
```
2019-10-23 15:32:40 +02:00
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.
2019-10-23 15:32:40 +02:00
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
You cannot display the bitmap yet, but in fxengine, it is not a priority.
However, you can display a specific pixel with `fe_bitmap_display_px()`, or you can get its color with `fe_bitmap_get_px`.