I'm kind of confused as to the way C# saves bitmaps. I currently use this statement to save a bitmap to (virtually) any extension (.ico, .dds, etc.).
Bitmap.Save(FileName);
This actually works for any extension I choose, but I'm having doubts it's saving in correct format. Reason for said doubts is because I found another article here, How to save Bitmap as icon?, which does so like:
// Create a Bitmap object from an image file.
Bitmap bmp = new Bitmap(sFn);
// Get an Hicon for myBitmap.
IntPtr Hicon = bmp.GetHicon();
// Create a new icon from the handle.
Icon newIcon = Icon.FromHandle(Hicon);
//Write Icon to File Stream
System.IO.FileStream fs = new System.IO.FileStream(destFileName, System.IO.FileMode.OpenOrCreate);
newIcon.Save(fs);
Which is obviously way different. So two questions:
- How can/does the first approach work if the second is the "correct" way?
- Would I need to customize save properties for each individual extension I wish to support or is the first method sufficient for any extension?