0

Using BitmapDecoder and BitmapFrame I can determine the images pixels size and resolution without reading the entire file. My reason for this is the files I'm dealing with are huge.

Using Guid guid = decoder.CodecInfo.ContainerFormat; I'm not sure how and what to compare this value to if at all possible.

I'm trying to determine the file type (BMP, PNG, etc)

Any help?

VC.One
  • 14,790
  • 4
  • 25
  • 57
Tony Teveris
  • 165
  • 10
  • 1
    If you don't mind adding System.Drawing to your app you can do like this: https://stackoverflow.com/questions/55869/determine-file-type-of-an-image – Isma Sep 19 '17 at 19:18
  • 1
    What value do you get? What happens if you type the following into Google.com : `C# "BitmapDecoder" "CodecInfo" format types`... this _should_ find a page from the manual (MSDN site) that explains what those values mean. Personally, I would just check the first few bytes. If you can try checking a Jpeg's first two bytes and getting a result like first=255 (of hex `FF`) and second=216 (hex `D8`) then you're ready and I'll advise further about format signatures within bytes. – VC.One Sep 19 '17 at 19:36
  • 2
    This [**Answer**](https://stackoverflow.com/a/12451102/2057709) from @Isma's link might help you check via bytes... – VC.One Sep 19 '17 at 19:39
  • All good answers, I ended up doing the character thing. – Tony Teveris Sep 21 '17 at 10:14

0 Answers0