Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving image to file

I am working on a basic drawing application. I want the user to be able to save the contents of the image.

enter image description here

I thought I should use

System.Drawing.Drawing2D.GraphicsState img = drawRegion.CreateGraphics().Save(); 

but this does not help me for saving to file.

like image 614
Victor Avatar asked Oct 16 '12 07:10

Victor


People also ask

Why can't I save an image as a JPEG?

From Start> Control Panel (or Start> Settings> Control Panel)> Default Programs> select Windows Photo Viewer> click on Set this program as default. Then, also from Default Programs> Associate a file type> select JPG and select Windows Photo Viewer. Repeat for JPEG and JPE.

How do I save my file as a JPEG?

Right click on the file and navigate to the Open with option. Open in Paint. Select the File Menu and the Save As option. Select JPEG from the menu.

How can I save an image as a PDF?

Using Google Chrome, you can save any picture as a PDF file. Open the image in Chrome and press Ctrl+P or go to the menu (the three horizontally stacked dots) and choose Print. Select the Destination drop-down menu and choose Save as PDF. Select Save.


2 Answers

You could try to save the image using this approach

SaveFileDialog dialog=new SaveFileDialog(); if (dialog.ShowDialog()==DialogResult.OK) {    int width = Convert.ToInt32(drawImage.Width);     int height = Convert.ToInt32(drawImage.Height);     Bitmap bmp = new Bitmap(width, height);            drawImage.DrawToBitmap(bmp, new Rectangle(0, 0, width, height));    bmp.Save(dialog.FileName, ImageFormat.Jpeg); } 
like image 140
Steve Avatar answered Sep 21 '22 01:09

Steve


You can try with this code

Image.Save("myfile.png", ImageFormat.Png) 

Link : http://msdn.microsoft.com/en-us/library/ms142147.aspx

like image 28
Aghilas Yakoub Avatar answered Sep 25 '22 01:09

Aghilas Yakoub