Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
1
Answer
Display image on Bitmap
asma
16y
11.6k
1
Reply
i am trying to pick a image file from open dialog box and send to other user in C#.net
private System.Windows.Forms.OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.RestoreDirectory = true;
openFileDialog1.FileName = "";
openFileDialog1.Filter = "Graphic Interchange Format (*.gif)|*.gif|" +
"JPEG File Interchange Format (*.jpg;*.jpeg)|*.jpg;*.jpeg";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);
File.Copy(openFileDialog1.FileName, Application.StartupPath + "\\Temp\\" + filename, true);
string fname = Application.StartupPath + "\\Temp\\" + filename;
if(File.Exists(fname))
WhiteBoard1.iSelected = fname;
FileInfo info = new FileInfo(WhiteBoard1.iSelected);
long filesize = info.Length;
if(filesize>0)
{
WhiteBoard1.strConfid = strConfid;
WhiteBoard1.LoadImage();
}
}
In whiteboard class
public void LoadImage()
{
try
{
Graphics grphs = CreateGraphics();
if(File.Exists(iSelected))
{
Image img1 = Image.FromFile(iSelected);
pict.Image=img1;
}
}
catch(OutOfMemoryException)
{
MessageBox.Show(msg.ToString());
}
}
I get exception as
OutofMemory Exception
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
Serializable
IFormatProvider.GetFormat