473,412 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Display image on Bitmap

i am trying to pick a image file from open dialog box and send to other user in C#.net

Expand|Select|Wrap|Line Numbers
  1. private System.Windows.Forms.OpenFileDialog openFileDialog1 = new OpenFileDialog();
  2. openFileDialog1.RestoreDirectory = true;
  3. openFileDialog1.FileName = "";
  4. openFileDialog1.Filter = "Graphic Interchange Format (*.gif)|*.gif|" +
  5. "JPEG File Interchange Format (*.jpg;*.jpeg)|*.jpg;*.jpeg";
  6. if (openFileDialog1.ShowDialog() == DialogResult.OK)
  7. {
  8. string filename = openFileDialog1.FileName.Substring(openFileDialog1.FileName.LastIndexOf("\\") + 1);
  9. File.Copy(openFileDialog1.FileName, Application.StartupPath + "\\Temp\\" + filename, true);
  10. string fname = Application.StartupPath + "\\Temp\\" + filename;
  11. if(File.Exists(fname))
  12. WhiteBoard1.iSelected = fname;
  13.  
  14. FileInfo info = new FileInfo(WhiteBoard1.iSelected);
  15. long filesize = info.Length;
  16. if(filesize>0)
  17. {
  18.  
  19. WhiteBoard1.strConfid = strConfid;
  20. WhiteBoard1.LoadImage();
  21. }
  22. }
  23.  
  24. In whiteboard class
  25.  
  26. public void LoadImage()
  27. {
  28. try
  29. {
  30. Graphics grphs = CreateGraphics();
  31.  
  32. if(File.Exists(iSelected))
  33. {
  34. Image img1 = Image.FromFile(iSelected);
  35. pict.Image=img1;
  36. }
  37. }
  38. catch(OutOfMemoryException)
  39. {
  40.  
  41. MessageBox.Show(msg.ToString());
  42.  
  43. }
  44. }
  45.  
I get exception as

OutofMemory Exception
Jun 18 '08 #1
4 1142
Plater
7,872 Expert 4TB
Your picture is too big? You don't have enough memory?
Jun 18 '08 #2
balame2004
142 100+
You should know your picture size in pixels. Only limited size of picture can be shown.
Jun 18 '08 #3
Your picture is too big? You don't have enough memory?
My image size doesnt matter it doesnt work for 1kb or for more than that.
Jun 19 '08 #4
Plater
7,872 Expert 4TB
My image size doesnt matter it doesnt work for 1kb or for more than that.
then I would say you have a recursive loop somewhere.
Set a breakpoint and follow the code flow. You will probably see that it is looping somewhere.
You are also not disposing of your image objects, that needs to be done.
Jun 19 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Wally | last post by:
I am trying to display images from an Access 2000 database and I get an error "Invalid Parameter Used" when I execute the code line "picBLOB.Image = Image.FromStream(stmBLOBData)" in my Visual...
1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
2
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
4
by: Dean L. Howen | last post by:
I create my own file format that could content many image files (jpg, ico, ....) . I can get the data of each image, and I want to display it on the form. How can? I've tried to create a file with...
11
by: Tina | last post by:
I'm in a button clicked event on mainpage.aspx. I want to display a new webpage that has just my image, which is a jpg. I want the page to be a ..jpg not an aspx so that it will be easy for the...
1
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to...
3
by: Bama | last post by:
I already stored the image in the SQL database. How do I retrieve it? Any help is appreciated.
0
by: adubra | last post by:
Hi there, I am using a device context (DC) and a buffer to successfully draw to screen. However, when I update the DC at very high frame rate and drag the frame containing the image very quickly...
0
by: manjitsarma | last post by:
I need to display an image in 'Image Control' of aspx page.Now the image is displayed in the aspx page itself.But I need to display it in 'Image Control'.This is a map application and the image is...
1
by: a.mustaq | last post by:
Hi All, In my application, I have to display tiff images stored on server. Please help me in acheaving this. With Regards, Mustaq Ahmed.A
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.