Can any PixelFormat be used with any ImageFormat?
Can any PixelFormat be used with any ImageFormat?
I am doing image processing with System.Drawing.Bitmap. When I create a Bitmap, I am asked about the PixelFormat; when i save the bitmap i am asked about ImageFormat. Are there invalid combinations here?
To help answer, here is a list of PixelFormats and ImageFormats:
PixelFormats ( MSDN - System.Drawing.PixelFormat ):
Gdi* Alpha* PAlpha* Extended* Canonical* Undefined* DontCare* Max* Format1bppIndexed Format4bppIndexed Format8bppIndexed Format16bppGrayScale** Format16bppRgb555 Format16bppRgb565 Format16bppArgb1555 Format24bppRgb Format32bppRgb Format32bppArgb Format32bppPArgb Format48bppRgb Format64bppArgb Format64bppPArgb
* - throws an ArgumentException when passed to a new bitmap ()
** - Doesn't work with any ImageFormat
ImageFormats ( MSDN - System.Drawing.ImageFormat ):
Bmp
Emf
Exif
Gif
Icon
Jpeg
MemoryBmp
Png
Tiff
Wmf
EDIT 1 : Updated PixelFormat list with PixelFormats that throw an exception when creating a Bitmap.
EDIT 2 : Doing some of my own tests, it seems that the PixelFormat " Format16bppGrayScale " is incompatible with all ImageFormats. Still looking for other incompatibilities ...
EDIT 3 : It seems to me like using Format32bppArgb for ImageFormats that support transparency, and Format24bppRgb for formats that don't work well enough.
source to share
No one has answered this question yet
Check out similar questions: