Extract information about PNG image in .NET.

I'm trying to get information about a PNG file, but I have yet to open a comprehensive site to help me.

Here 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 this, I was able to get the height and width of the image. However, I still need to find the following information:

  • Is this RLE encoding?
  • Is it in native video format?
  • Is it spinning?
  • Does he use a grayscale palette?
  • Does it have transparency?
  • Is it RGB or BGR?

I would really appreciate some guidance on how to achieve this, or links to good articles dedicated to this. We are working with .NET 4.0

+2


a source to share


1 answer


I'm not sure if this will help you, but the best I've seen so far is to move the image pixel by pixel in a loop and do various tasks.

See answers for examples:



+1


a source







All Articles