Using a buffer to read in data from file, then display on SPI OLED

Recently I saw a lad on youtube playing a video on an OLED using an esp32 running micropython, and I wanted to try it out using an Arduino nano. Using python files he provided I converted some videos into .dat files and loaded them into my SD card. Using Adafruits SSD 1306 library I tried to read 1024 bytes of a file into a buffer and upload the buffer into the OLED, but I'm having trouble making that work.

Below is my current program:

display.clearDisplay();
myFile = SD.open("ducktale.dat");

//myFile.read(buffer, sizeof(buffer));
// Serial.println(myFile);

if (myFile) {
Serial.println("ready");

//read from file till nothing is left, but 1024 bytes at a time
//Then push the bytes to the oled.
byte buf[1024];

while (myFile.available()) {
myFile.read(buf, sizeof(buf));

display.clearDisplay();

display.drawBitmap(0, 0, buf , 128, 64, WHITE);

display.display();

}
//close file when done:
myFile.close();
} else {
Serial.println("error opening file!");
}
}

Thanks for you help!

Hi Newbee,
here is a link with tips how to speed up getting good answers
best regards Stefan

I seriously doubt that a nano has sufficient memory to do what you want, it only has 2K bytes of ram (dynamic memory). When you compile the code, how much dynamic memory does the compiler show as being used for global variables? You will need 1024 bytes more than that just for your image buffer (local variables are not included in the total shown by the compiler).