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.

+3
.net system.drawing


source to share


No one has answered this question yet

Check out similar questions:

890
How can I get the app path in a .NET console app?
867
How can I generate random alphanumeric strings?
677
How to get the version of an assembly file
497
Which method works better: .Any () vs .Count ()> 0?
452
What does Visual Studio's Any Processor target mean?
8
Programmatically select the JPEG or PNG conversion format for Silverlight display
3
ImageResizer / System.Drawing and CMYK JPEG
3
Why are JPEG images created with System.Drawing larger than original bitmaps?
2
Image.Save () on MemoryBmp on TIFF with EncoderParams - How?
1
Error loading Bitmap from MemoryStream



All Articles
Loading...
X
Show
Funny
Dev
Pics