473,386 Members | 2,042 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,386 software developers and data experts.

How to save image from picturebox using c#

19
Hi,

i need help on how to save the image that return from picturebox?

basically the program works,
1)Read image (.png)--> load into pictureBox1
2)Fire button save to save the image from pictureBox1

Here i place code:

Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace OpenSaveImage
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.  
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         Bitmap OriginalImage;
  21.  
  22.  
  23.         private void btnOpen_Click(object sender, EventArgs e)
  24.         {
  25.             //Open File Dialog to load image files
  26.             openFileDialog1.FileName = "";
  27.             openFileDialog1.Title = "Images";
  28.  
  29.             //Filter the filedialog, so that it will show only the mentioned format images
  30.             openFileDialog1.Filter = "PNG Image(*.png)|*.png|JPG Image(*.jpg)|*.jpg|BMP Image(*.bmp)|*.bmp";
  31.             openFileDialog1.ShowDialog();
  32.  
  33.             if (openFileDialog1.FileName.ToString() != "")
  34.             {
  35.                 Box1.ImageLocation = openFileDialog1.FileName.ToString();
  36.                 OriginalImage = new Bitmap(openFileDialog1.FileName.ToString());
  37.             }
  38.  
  39.             butSave.Enabled = true;
  40.         }
  41.  
  42.        // private void butSave_Click(object sender, EventArgs e)
  43.        // {
  44.          //   SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  45.          //   saveFileDialog1.Filter = "PNG Image(*.png)";
  46.          //   if (saveFileDialog1.ShowDialog() == DialogResult.OK)
  47.          //   {
  48.                 //saveImg(saveFileDialog1.FileName, new Bitmap(OriginalImage), 85L);
  49.          //   }
  50.     //    }
  51.  
  52.  
  53.         /*
  54.          * Code for save image
  55.          */
  56.  
  57.  
  58.  
  59.     }
  60. }
  61.  
hope someone could help me, thank you
Aug 4 '10 #1
2 7414
Christian Binder
218 Expert 100+
Try
Box1.Image.Save(filename);

But I don't know if it converts automatically to png if you load another Image.
Mabye you look at msdn
Aug 4 '10 #2
Curtis Rutland
3,256 Expert 2GB
Image.Save lets you specify an image format.
Aug 4 '10 #3

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

Similar topics

4
by: jack | last post by:
Hi. I wanted to save image from the form in my accss database. there is one picture box on form which loads the picture from the harddisk . i want this picture to store in my database .. thanks...
4
by: Hrvoje Vrbanc | last post by:
I would like to know the most efficient way to copy an image from an Internet URL to the local hard disk by means of using an ASP.NET page. So, I would like to click the button on the ASP.NET...
2
by: kimiraikkonen | last post by:
Hello, I want to save a picture using that code and i have a read-only textbox on the picturebox1 named "textbox2". I want users to enter their custom text using "textbox1" and save the image...
1
by: chandan | last post by:
Hi, I am in search of a control that can save image form my webpage. On that web page I am using my own context menu and I disabled the default context menu of IE. Now I want the same...
0
by: hnpatel | last post by:
hello friends, i m making application in vb.NET. i m using MY SQL 5.0 and vs 2005 for this application. Now I want to save image file in sql database. i m using blob datatype of image field. i...
6
by: Jerry Spence1 | last post by:
I am using a network camera that saves the image in a byte array in memory (via their ocx component, and in the OnNewImage event I can get the pointer to the image and the byte length as...
1
ranjana1980
by: ranjana1980 | last post by:
In my project of desktop application using c#.net save image in database during registration of student But it is not mandatory.Without Browse the image i click on insert button it gives error "Empty...
2
by: rajeshkumarswain | last post by:
hi friends, I am new in php and i am trying to save image to database. Please provide a sample.
3
by: regan2007 | last post by:
How are you going to save image in database using php?Please explain it if you do kno
1
by: sushant191 | last post by:
Hi Everyone , can any one tell me, how to save image url path in variable using fckeditor built-in image browser for ex.(~/userfiles/image1.jpg). I m not uploading image from outside fckeditor. Pls...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.