2010-05-05 22 views
2

我正在尝试获取有关PNG文件的信息,但我尚未发现一个综合站点以帮助我。在.NET中提取关于PNG的图像信息

这些都是一些半有用的代码片段我有:

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

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]; 

有了这些我已经能够获得图像的高度和宽度。但是我仍然需要发现以下信息:

  • 它是否被编码?
  • 它是原生视频格式吗?
  • 是否旋转?
  • 它使用灰度调色板吗?
  • 它有透明度吗?
  • 它是RGB还是BGR?

我真的很感激一些关于如何实现这个目标的链接,或者链接到处理这个问题的好文章。我们正在使用.NET 4.0

回答