2

I'm trying to get information about a PNG file but I've yet to discover a comprehensive site to help me.

These are some of the semi useful code snippets I have:

Bitmap bmp = new Bitmap(pngFileName);
BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly,PixelFormat.Format48bppRgb);

and

Stream imageStreamSource = new FileStream(pngFileName, FileMode.Open, FileAccess.Read, FileShare.Read);
var decoder = new PngBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);

BitmapSource bitmapSource = decoder.Frames[0];

With these I've been able to to get the image height and width. However I still need to discover the following information:

  • Is it RLE encoded?
  • Is it in native video format?
  • Is it rotated?
  • Does it use a grayscale palette?
  • Does it have a transparency?
  • Is it RGB or BGR?

I'd really appreciate some pointers on how to acheive this or links to good articles dealing with this. We're working with .NET 4.0

Mark
  • 2,392
  • 4
  • 21
  • 42

1 Answers1

1

I'm not sure if that helps you, but the best I've seen so far, is to walk the image pixel by pixel in a loop and accomplish your different tasks.

See these answers for examples:

Community
  • 1
  • 1
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144