Enum BmpCompression
How a BMP's pixels are stored.
public enum BmpCompression
Fields
AlphaBitfields = 5Uncompressed, with red, green, blue and alpha masks.
Bitfields = 4Uncompressed, with red, green and blue masks.
Huffman1D = 8CCITT modified Huffman 1-bit rows (OS/2 2.x), read but not written.
Jpeg = 6A whole JPEG file.
None = 0Uncompressed, with the default channel layout for the bit depth.
Png = 7A whole PNG file.
Rle24 = 3Run-length encoded 24-bit colors (OS/2 2.x).
Rle4 = 2Run-length encoded 4-bit indices.
Rle8 = 1Run-length encoded 8-bit indices.
Examples
// Each reader fills in what the file's header says, in the format's own terms.
using Raster png = Raster.Load("duck.png");
if (png.Metadata.FormatDetails is PngDetails pngDetails)
{
Console.WriteLine($"PNG {pngDetails.ColorType}, {pngDetails.BitDepth}-bit, interlaced: {pngDetails.Interlaced}");
foreach (PngTextSource source in pngDetails.TextSources)
{
Console.WriteLine($"Text from a {source.ChunkType} chunk, compressed: {source.Compressed}");
}
}
using Raster bmp = Raster.Load("duck.bmp");
BmpDetails bmpDetails = (BmpDetails)bmp.Metadata.FormatDetails!;
Console.WriteLine($"BMP {bmpDetails.BitsPerPixel}-bit, {bmpDetails.Compression}, {bmpDetails.HeaderSize}-byte header");
using Raster tga = Raster.Load("duck.tga");
TgaDetails tgaDetails = (TgaDetails)tga.Metadata.FormatDetails!;
Console.WriteLine($"TGA type {tgaDetails.ImageType}, origin {tgaDetails.Origin}, alpha {tgaDetails.AlphaType}");
using Raster qoi = Raster.Load("duck.qoi");
QoiDetails qoiDetails = (QoiDetails)qoi.Metadata.FormatDetails!;
Console.WriteLine($"QOI {qoiDetails.Channels} channels, linear: {qoiDetails.Linear}");
using Raster pgm = Raster.Load("duck.pgm");
PnmDetails pnmDetails = (PnmDetails)pgm.Metadata.FormatDetails!;
Console.WriteLine($"PNM {pnmDetails.Kind}, maxval {pnmDetails.MaxValue}, plain text: {pnmDetails.PlainText}");