G
Guest
Hi,
I want to display the Photos from a Folder in a Picture Box for my windows
mobile 5.0 application.
User can view the photos by pressing the Next Button.
But it is throwing out of memory Exception when he navigates through more
than 5 photos.
Here is my code.
private void ShowPhoto()
{
PicBxPhoto.Image = null;
Bitmap BmpPhoto = null;
// sets the path for the Bitmap
BmpPhoto = new Bitmap(PhotoList[iSelPhotoIndex].FullName);
// Display the selected photo in the picture box
PicBxPhoto.Image = BmpPhoto;
// free the bitmap after display
BmpPhoto.Dispose();
BmpPhoto = null;
}
}
private void BtnNext_Click(object sender, EventArgs e)
{
if (PhotoList.Length != iSelPhotoIndex + 1)
{
// Load the next photo in the Photolist
iSelPhotoIndex++;
string[] photoName =
PhotoList[iSelPhotoIndex].Name.Split('.');
// display the corresponding Job No. and Creation time of
the photo
LblName.Text = photoName[0];
LblDateTime.Text =
PhotoList[iSelPhotoIndex].CreationTime.ToString();
// display the photo in picture box
ShowPhoto();
LblName.Refresh();
LblDateTime.Refresh();
}
}
Can someone please tell me why this small code is throwing Out of Memory
Exception?
Thanks,
Murthy
I want to display the Photos from a Folder in a Picture Box for my windows
mobile 5.0 application.
User can view the photos by pressing the Next Button.
But it is throwing out of memory Exception when he navigates through more
than 5 photos.
Here is my code.
private void ShowPhoto()
{
PicBxPhoto.Image = null;
Bitmap BmpPhoto = null;
// sets the path for the Bitmap
BmpPhoto = new Bitmap(PhotoList[iSelPhotoIndex].FullName);
// Display the selected photo in the picture box
PicBxPhoto.Image = BmpPhoto;
// free the bitmap after display
BmpPhoto.Dispose();
BmpPhoto = null;
}
}
private void BtnNext_Click(object sender, EventArgs e)
{
if (PhotoList.Length != iSelPhotoIndex + 1)
{
// Load the next photo in the Photolist
iSelPhotoIndex++;
string[] photoName =
PhotoList[iSelPhotoIndex].Name.Split('.');
// display the corresponding Job No. and Creation time of
the photo
LblName.Text = photoName[0];
LblDateTime.Text =
PhotoList[iSelPhotoIndex].CreationTime.ToString();
// display the photo in picture box
ShowPhoto();
LblName.Refresh();
LblDateTime.Refresh();
}
}
Can someone please tell me why this small code is throwing Out of Memory
Exception?
Thanks,
Murthy