BitmapInfoHeader

BmpImage.BitmapInfoHeader property

获取位图信息头

public BitmapInfoHeader BitmapInfoHeader { get; }

适当的价值

位图信息头。

例子

以下示例从 BMP 标头获取信息并将其打印到控制台。

[C#]

using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(@"c:\temp\sample.bmp"))
{
    Aspose.Imaging.FileFormats.Bmp.BmpImage bmpImage = (Aspose.Imaging.FileFormats.Bmp.BmpImage)image;
    Aspose.Imaging.FileFormats.Bmp.BitmapInfoHeader header = bmpImage.BitmapInfoHeader;

    System.Console.WriteLine("The number of palette colors that are required for displaying the bitmap: {0}", header.BitmapColorsImportant);
    System.Console.WriteLine("The number of palette colors used in the bitmap: {0}", header.BitmapColorsUsed);
    System.Console.WriteLine("The bitmap compression: {0}", header.BitmapCompression);
    System.Console.WriteLine("The bitmap height: {0}", header.BitmapHeight);
    System.Console.WriteLine("The bitmap width: {0}", header.BitmapWidth);
    System.Console.WriteLine("The bitmap raw data size in bytes: {0}", header.BitmapImageSize);
    System.Console.WriteLine("The number of planes: {0}", header.BitmapPlanes);
    System.Console.WriteLine("The horizontal resolution of the bitmap, in pixels-per-meter: {0}", header.BitmapXPelsPerMeter);
    System.Console.WriteLine("The vertical resolution of the bitmap, in pixels-per-meter: {0}", header.BitmapYPelsPerMeter);
    System.Console.WriteLine("The number of bits per pixel: {0}", header.BitsPerPixel);
    System.Console.WriteLine("The extra bits masks: {0}", header.ExtraBitMasks);
    System.Console.WriteLine("The header size in bytes: {0}", header.HeaderSize);
}

//输出可能如下所示:
//显示位图所需的调色板颜色数:0
//位图中使用的调色板颜色数:0
//位图压缩:0
//位图高度:375
//位图宽度:500
//位图原始数据大小,以字节为单位:562500
//平面数:1
//位图的水平分辨率,以每米像素为单位:0
//位图的垂直分辨率,以每米像素为单位:0
//每个像素的位数:24
//额外的位掩码: 
//以字节为单位的标头大小:40

也可以看看