bpp = bits per pixel, so 32bpp means 8/8/8/8 for R/G/B/A.
Like .NET has an enum for these "System.Drawing.Imaging.PixelFormat".
Now once I have a Bitmap or Image object with my graphics, how would I save it to a file / what format would I use?
What image file format (JPEG/GIF/PNG) supports low bit-depths like 16bpp or 8bpp (instead of the usual 32bpp or 24bpp)
All image formats effectively support low bit depths. You just leave the last bits unused, if not needed. GIF only supports low-color; you're restricted to 256 colors.
One bit per pixel
This produces the smallest possible PNG from .Net only. Note that it is b&w - not even grayscale. Useful for documents.
Consumer code:
Make1bpp
This is what the PNG encoder cares about
Try this:
Untested code -
Look at the System.Drawing.Imaging namespace and have a play with the Encoder.xxx parameter settings and the image.Save method. HTH.
Update also worth noting that if you want a small image (low byte count) you can try saving as JPEG an using Encoder.Compression compression but at image quality cost.
I don't think the other's answering tested their code as GDI+ PNG does not support the Encoder.BitDepth EncoderParameter. In fact, the only Codec which does is TIFF.
You need to change your image's PixelFormat before saving in order to have any effect out the output. This won't always produce the PixelFormat you expect. See my post here for more information on which PixelFormats turn into what.
As for PixelFormat conversions, something like the following will work:
Unfortunately, these conversions can produce some really bad output. This is especially true in the case where you are performing a lossy conversion (high bit depth to lower).