예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
0
        public override bool Equals(object obj)
        {
            BitmapFile rhs = obj as BitmapFile;

            return(this == rhs);
        }