If this were a true Bitmap you could open the file as a stream and read chunks of it. But I see that you’re using JPEG. This is probably part of the problem. JPEG uses compression so on disk and in RAM it’s small. But when the JPEG is converted to a true bitmap (to send the screen the bits to display it) the size is Height * Width * Color Bits.
You could either save your images in smaller tiles (maybe six 320x40 images) and shuffle them out (I recommend trying this first), or switch to using a bitmap so you can stream chunks of it. Streaming chunks might look something like this…
int bitmapHeaderSize = 54; //Bitmaps have a 54byte header.
int chunkSize = 320 * 40 * 3; //Assuming you want 40 line chunks and you're using 24 bit color (3 bytes for 24 bits).
byte chunk = new byte[chunkSize];
byte chunkWithHeader = new byte[chunkSize + bitmapHeaderSize];
Bitmap bmp = null;
FileStream fs = System.IO.File.OpenRead("yourfilepath");
fs.Read(chunkWithHeader, 0, 54); //This loads the header into your buffer.
//Bytes 22 - 25 in the header contain the height. We need to change that to 40.
chunkWithHeader = 0x28; //40 in Big-Endian binary is 0010 1000 0000 0000
chunkWithHeader = 0;
chunkWithHeader = 0;
chunkWithHeader = 0.
for (int i = 54; i < fs.Length; i += chunkSize) //We start at the header
if (fs.Length < (i + chunkSize))
chunkSize = ((int)fs.Length - i);
fs.Read(chunk, i, chunkSize);
Array.Copy(chunk, 0, chunkWithHeader, 54, chunk.Length); //I don't like this but I can't specify offets for fs.Read
bmp = new Bitmap(chunkWithHeader, Bitmap.BitmapImageType.Bmp);
display_N18.SimpleGraphics.DisplayImage(bmp, i * 40, 0);
…This code probably won’t work. I just typed it up without trying it. But you get the idea.
Also, the way you’re looping through the list of files is going to waste memory and performance will degrade as there are more files. Instead consider using the IEnumerable pattern…
fileEnumerator = System.IO.Directory.EnumerateFiles("\\SD");
foreach (string file in fileEnumerator)
//...Your code here.
This way only one string is in memory. This code will perform at the same speed with 1 or 10,000 files.