fxengine/include/fxengine/model/bitmap.md

1.9 KiB

Fxengine::Bitmap

This is part of the fxengine project. This file refers to bitmap.h header.

#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

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;

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 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 :

fe_bitmap bmp
{...};

Please use the function

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 ``