tags:

views:

449

answers:

4

This may be simple one, but 5 mins of Googling didn't give me the answer. How do you save and load bitmaps using .Net librabries?

I have an Image object and I need to save it to disk in some format (preferably png) and load back in later. A C# example would be great.

+1  A: 

About 10 seconds of google lead me to this example for the save method, you can dig around a bit more for the others.

Mitchel Sellers
+11  A: 

Here's a really simple example.

Top of code file

using System.Drawing;

In code

Image test = new Bitmap("picture.bmp");
test.Save("picture.png", System.Drawing.Imaging.ImageFormat.Png);

Remember to give write permissions to the ASPNET user for the folder where the image is to be saved.

Vincent McNabb
Make sure you have write permissions for ASP.NET on the folder you want to save.
Daniel A. White
`Bitmap` is in the `System.Drawing` assembly.
Alex Lyman
OK, added it into the answer.
Vincent McNabb
+1  A: 

Hiya, use the Image.Save() method.

A better explanation and code sample than I could provide can be found here:

MSDN

Shaun Austin