Cannot load image file - Out of memory exception
Hi,
I am not able to load an image , I am getting out of memory exception. The image size is only 70kb.I am fetching the image locally, then saving the image in application directory.I am the saving the location in database .Then fetching the image , while fetching the image I am getting out of memory exception.I should not crop the images.
/** Add Image **/
private void btnaddimage_Click(object sender, EventArgs e)
{
btnaddimage.Enabled = false;
if (ofdfiledialog.ShowDialog() == DialogResult.OK)
{
txtimages.Image = Image.FromFile(ofdfiledialog.FileName);
text1.Text =ofdfiledialog.FileName;
string fileName = this.ofdfiledialog.FileName;
text1.Text = fileName;
fileName = fileName.Substring(fileName.LastIndexOf("\\") +1);
text2.Text = fileName;
}
/** Save image**/
private void BtnSave_Click(object sender, EventArgs e)
{
try
{
if (dbfCmbImageType.Text == "")
{
MessageBox.Show("Mandatory Fields are Not Filled");
}
else
{
strFilePath = Application.ExecutablePath;
txtimages.Image.Save(strFilePath + text2.Text, System.Drawing.Imaging.ImageFormat.Jpeg);
str1 = strFilePath;
str2 = text2.Text;
dbfTxtImageURL.Text = str1;
dbfTxtImage.Text = str2;
txtimages.Image = null;
}
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}
}
}
//** Load Image**/
Path = dbfTxtImageURL.Text;
txtimages.Image = System.Drawing.Image.FromFile(Path);
//Out of memory
Thanks in Advance,
A.Durga Prasad