[Solved] Displaying images, various formats

  • Hi
    I would like to display images on the Fire's screen
    I've read docs about drawBitmap function, I've read the Lesson, I've read a seemingly complete tuto, but I still don't get it working (image as a c file from flash memory).
    What should the c file look like ? How do I call it in code?
    #include <M5Stack.h>
    #define imgName codeImage
    #define PicArray extern unsigned char
    PicArray imgName[];

    void setup() {
    M5.Lcd.drawBitmap(0,0,320, 240, (uint16_t *)imgName);
    void loop() {
    "codeImage.c" file:
    const unsigned char codeImage [] = {(
    0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, (...)0x00, 0x00, 0x00, 0x1f)};

    I used the UTFT library tool as recommended (libraries\UTFT\Tools\ImageConverter565.exe)
    It does work with M5.Lcd.pushImage instead of M5.Lcd.drawBitmap if I use imageToCode
    So I guess the key here is the c file...is there a detailed doc on this topic ?

  • M5Stack

    you could use this python script to create the conversion image to code


  • Thanx for your help
    Unfortunately it does not work for me
    instead of
    Does not even work with pushImage
    Are they parameters/arguments I should use?

  • In this file there is no simply an array containing each color component R, G, B for each subsequent pixel. The color code is expressed by a total of 16 bits: red 5 bits, green 6 bits and blue 5 bits from the top. In this case a color of one pixel is represented as a two values like [0xff,0xff, ...

    You must include this file with include directive and use name codeimage of this array as a parameter of function:

    M5.Lcd.drawBitmap(0,0,320, 240, codeimage);

    This file is concatenated with your code when compiling the program. And it is downloaded as a whole program to the device.

    You also try a .drawBmpFile() function or .drawJpgFile() to draw files directly from your device flash


  • @robalstona
    Thanx for your help
    I added the c file in the arduino IDE, that's how it's done in the example Factory Test
    It DOES work with the exemple (M5 logo) where the c file is given, that's why I suppose my problem is about converting jpg/bmp -> c file
    There are a lot of converters out there, none gave me a c file that could be correctly displayed with drawBitmap

  • Jpg and bmp images require some specific formatting but they are usable direct in code if the image is uploaded to the cores memory, for examples on this please search the forum as I did work hard to find out the exact specification the file has to be in.

  • Believe me I did search...the forum and many other places...At the moment I'm trying to "reverse engineer" the only c filethat is working

  • Well...using only 320x240 input and "ImageToCode" converter it seems to be OK not always but most of the time
    Thanks for your help

  • maybe you try open your image in image editor and save it with 16bit color BMP (not 24bit) before use program to convert