#include "bmp_writer/bmp_writer.h" /** * User's callback function which returns color of particular pixel on the * screen. * * Since it is fictional screenshot, this function just generates a gradient. */ static T_BmpWr_Color32 _bmp_pix_color_get_32( uintptr_t user_data, T_BmpWr_Coord x, T_BmpWr_Coord y ) { return BMP_WR__COL_RGB_32bit(0x00, 0xff - x, x); } int main(void) { //-- Create struct with params for bmp generator T_BmpWriter_CtorParams writer_ctor_params = { //-- Main image params: color depth, size .color_depth = BMP_WR_COL_DEPTH__24, .width = 256, .height = 50, //-- User's callback functions .callback = { //-- for this mode, we need just one function that returns color for // 24- and 32-bit images .func = { .bpp_24_32 = { .p_pix_color_get = _bmp_pix_color_get_32, }, }, }, }; //-- Create T_BmpWriter object with appropriate params T_BmpWriter *p_bmp_writer = new_bmp_writer(&writer_ctor_params); //-- Now, byte by byte, retrieve all the data! while (bmp_writer__available_data_len__get(p_bmp_writer) > 0){ char cur_char = bmp_writer__next_byte__get(p_bmp_writer); //-- Now, cur_char contains next byte of the bmp file data. // We're free to do whatever we want with it: maybe fill some // fixed-size buffer that will be written to flash when buffer is // full, or transmit somewhere, or anything. } //-- Done; image is generated. // Delete the object. delete_bmp_writer(p_bmp_writer); return 0; }