Skip to content

Newbie question on getting Pixel Format from an image #2682

Answered by antonfirsov
iMrShadow asked this question in Q&A
Discussion options

You must be logged in to vote

Note that System.Drawing's Image.PixelFormat doesn't necessarily represent the format used in the "original image", if you mean the encoded file by that. While it's correct for a PNG, note that JPEG stores images in YCbCr color space, meaning if you don't ask for a specific format when decoding, the outcome, new Bitmap("img.jpg").PixelFormat == PixelFormat.Format24bppRgb is not really accurate. Long story short Image.PixelFormat is the format System.Drawing decides to internally represent your image in when you are not asking for a specific format at decoding, and not the absolute thruth about the source image.

ImageSharp will also pick an arbitrary pixel format when using the non-generic I…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@iMrShadow
Comment options

@antonfirsov
Comment options

@JimBobSquarePants
Comment options

@antonfirsov
Comment options

@JimBobSquarePants
Comment options

Answer selected by iMrShadow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants