Laman

Kamis, 05 Mei 2011

save the image with the specific type in C# (C Sharp)

 if previously posted about tutorial save an image from pictureBox, this time will discuss about saving the iamge form pictureBox with the image format type has been specified. Who have not read the tutorial on saving iages from the picture box please click here. In the tutorial code to save an image from pictureBox is as follows




if (DialogResult.OK == saveFileDialog1.ShowDialog()){                    pictureBox1.Image.Save(saveFileDialog1.FileName.ToString());
}

To save it with a certain format adds litle to the source abouve, after the modified source code above into the following

 if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image.Save(saveFileDialog1.FileName + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
            }
Here is a preview of the result of the program that has been running


   Figure 2. Preview when program load the image

Figure 3. Preview when program save the image (Open Save Dialog)

Figure 4. Preview result file image has been stored on the drive

For more details, please download the example program in here. and also download the project in here 
download file program disini
download file project(full) disini

Clue download : click the link download above, after which it will apear adf.ly pages, wait several second until the top right corner it show "skip ad", click the button, after which it will appear ziddu page, please click on the download button which appears on page ziddu
NB : All of program in this tutorial write using the IDE Visual Studio 2010. with the target framework 3.5

 

6 komentar: