public static BitmapFile ReadIndexed(BinaryReader seekableReader) { BitmapFile bitmapFile = new BitmapFile(); bitmapFile.bmpHeader = ReadBmpHeader(seekableReader); bitmapFile.imageHeader = ReadImageHeader(seekableReader); ReadPalette(seekableReader, bitmapFile); ReadPixels(seekableReader, bitmapFile); return(bitmapFile); }
public BitmapFile Clone() { BitmapFile bmp = new BitmapFile(); bmp.bmpHeader = bmpHeader.Clone(); bmp.imageHeader = imageHeader.Clone(); bmp.palette = new Color[palette.Length]; System.Array.Copy(palette, bmp.palette, palette.Length); bmp.pixels = new byte[pixels.Length]; System.Array.Copy(pixels, bmp.pixels, pixels.Length); return(bmp); }
private static void ReadPixels(BinaryReader seekableReader, BitmapFile bitmapFile) { uint pixelContainerSize = bitmapFile.bmpHeader.size - bitmapFile.bmpHeader.pixelOffset; VerifyPixelSizeMatchesImageDimensionsWithPitch(bitmapFile.imageHeader.bitCount, bitmapFile.imageHeader.width, bitmapFile.imageHeader.height, (int)pixelContainerSize); bitmapFile.pixels = new byte[pixelContainerSize]; for (int i = 0; i < bitmapFile.pixels.Length; ++i) { bitmapFile.pixels[i] = seekableReader.ReadByte(); } }
private static void ReadPalette(BinaryReader seekableReader, BitmapFile bitmapFile) { if (bitmapFile.imageHeader.usedColorMapEntries != 0) { bitmapFile.palette = new Color[bitmapFile.imageHeader.usedColorMapEntries]; } else { bitmapFile.palette = new Color[bitmapFile.imageHeader.CalcMaxIndexedPaletteSize()]; } for (int i = 0; i < bitmapFile.palette.Length; ++i) { bitmapFile.palette[i] = new Color(seekableReader); } }
public override bool Equals(object obj) { BitmapFile rhs = obj as BitmapFile; return(this == rhs); }