Click here to Skip to main content
16,018,904 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
its easy to convert the image format but i want to save the bitmat object as a png extention image or jpeg extention image....so need ur help
Posted
Comments
Nirav Prabtani 22-Jan-14 6:51am    
what have you tried for??

1 solution

If you have a Bitmap element, simply use the Save method and pass in the appropriate image format (from the System.Drawing.Imaging namespace). It looks something like this:
C#
public static void SavePng(this Bitmap image, string fileName)
{
  if (image == null) throw new ArgumentNullException("image");
  if (string.IsNullOrWhitespace(fileName)) throw new ArgumentException("file name has not been specified");

  image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
}
Then all you do in your code is:
C#
myBitmap.SavePng(_fileNameForPng);
It's as easy as that.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900