Reading BMP HEX code from SD and displaying on 0.96" OLED

Hi,
I want to read HEX code made from BMP from the SD card and than displaying it on the OLED display.
I don’t have problems with reading file, but I don’t know how to convert data from it to the “static const unsigned char” in which the image should be stored.

Here’s my code:

//Pretty normal stuff
#include <SPI.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h>
#include <SD.h>


File myFile;
#define filePath "logo.txt"

//OLED pins
#define OLED_DC 4  //OLED -- D/C
#define OLED_CS 8  //Not connect
#define OLED_CLK 7 //OLED -- SCL
#define OLED_MOSI 6 //OLED -- SDA
#define OLED_RESET 5//OLED -- RST
Adafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);

//And here we've got our char
static const unsigned char PROGMEM Logo[] = {
//blah blah blah
};

void setup(void)
{
  Serial.begin(115200);

  //OLED initialization
  display.begin(SSD1306_SWITCHCAPVCC);
  display.clearDisplay();

  if (!SD.begin(3)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  myFile = SD.open(filePath);
  if (myFile) {
    Serial.println(filePath);

    while (myFile.available()) {
      Serial.write(myFile.read());
    }
  } else {
    Serial.println("error opening logo.txt");
  }


  //------------
  //And here i want to read data from file and overwrite current char so it can be displayed as image later.
  //How am I supposed to do this?
  //------------
  static const unsigned char PROGMEM Logo[] = {myFile.read()};

  myFile.close();
}

//Again, pretty normal stuff
void loop()
{
  display.clearDisplay();

  display.drawBitmap(32, 0,  Logo, 64, 64, 1);

  display.display();
  delay(500);
}

I run it on the Mega cause Uno doesn’t have enough memory.

I hope someone can help me with this, thanks!

but I don't know how to convert data from it to the "static const unsigned char" in which the image should be stored.

The type is NOT "static const unsigned char". It is "static const unsigned char PROGMEM ". That is, an array of chars in program memory. You can not write to program memory at run time, so there is no way to get the data from the SD file into a variable of type static const unsigned char PROGMEM .

You will need to investigate modifying the library to add an overload of the drawBitmap() function that does not expect the array to be const or in program memory.