stm32-ssd1306 icon indicating copy to clipboard operation
stm32-ssd1306 copied to clipboard

add img2code

Open kossnikita opened this issue 2 months ago • 9 comments

Image to C code converter

img2code script converts images to C byte array (bitmap)

./img2code.py image.png

Which can be drawn on display by library

Example:

extern const SSD1306_bitmap_t bitmap;
ssd1306_DrawBitmap(0, 0, bitmap.bitmap, bitmap.w, bitmap.h, White);
ssd1306_UpdateScreen();

Animation

You can even convert GIF files!

./img2code.py animation.gif

This generates a bitmap for each frame, which can be accessed by index

Example:

extern const SSD1306_animation_t animation;
for(uint32_t i = 0; i < animation.frames; i++)
{
    ssd1306_DrawBitmap(0, 0, animation.frame[i], animation.w, animation.h,
                         White);
    ssd1306_UpdateScreen();
    delay_ms(200);
}

kossnikita avatar Apr 05 '24 12:04 kossnikita