One question do you have mounted storage?
Something like this:
class FlashCard
{
public byte[] picData;
public PersistentStorage sd_card;
....
In FlashCard class:
private static void MountStorage(string storage)
{
try
{
sd_card = new PersistentStorage(storage);
sd_card.MountFileSystem();
// Format the media if it was not.
VolumeInfo sdvolumeinfo = new VolumeInfo(storage);
if (!sdvolumeinfo.IsFormatted)
{
sdvolumeinfo.Format("FAT", 32, true);
}
}
catch (Exception)
{
}
}
public void ShowPic()
{
FlashCard flash = new FlashCard();
flash.MountStorage("SD");
flash.testSD();
Bitmap img = new Bitmap(flash.picData , Bitmap.BitmapImageType.Bmp);
LCDPanel.Clear();
LCDPanel.DrawImage(0, 0,img, 0, 0, 272, 480);
LCDPanel.Flush();
}
If this will work for you then you need move MountStorage() method to your main class and call it on device start only once and not in each ShowPic() request …
The following crash: First code is snippet from the main, class Programm
....
sdCard.testSD(); //read file from sd card to picdata
Thread.Sleep(1000);
lcd.ShowPic(); //show picdata on screen
Class Display:
public void ShowPic()
{
FlashCard flash = new FlashCard();
Bitmap img = new Bitmap(flash.picData , Bitmap.BitmapImageType.Bmp);
LCDPanel.Clear();
LCDPanel.DrawImage(0, 0,img, 0, 0, 272, 480);
LCDPanel.Flush();
}
The above code will crash ath the bitmap img line, but when I in the class Programm remove the line sdCard.testSD(); and do the following in the class Display
public void ShowPic()
{
FlashCard flash = new FlashCard();
flash.testSD(); //read bitmap from sd card and put in picData
Bitmap img = new Bitmap(flash.picData , Bitmap.BitmapImageType.Bmp);
LCDPanel.Clear();
LCDPanel.DrawImage(0, 0,img, 0, 0, 272, 480);
LCDPanel.Flush();
}