예제 #1
0
        void ReadBMP()
        {
            FileStream   BMP     = new FileStream(name, FileMode.Open);
            BinaryReader dataout = new BinaryReader(BMP);

            HeadBMP           = new HeaderBMP();
            HeadBMP.bfType    = dataout.ReadInt16();
            HeadBMP.bfSize    = dataout.ReadUInt32();
            HeadBMP.Reserved1 = dataout.ReadInt16();
            HeadBMP.Reserved2 = dataout.ReadInt16();
            HeadBMP.bfOffBits = dataout.ReadInt32();

            HeadBMP.biSize          = dataout.ReadUInt32();
            HeadBMP.biWidth         = dataout.ReadInt32();
            HeadBMP.biHeight        = dataout.ReadInt32();
            HeadBMP.biPlanes        = dataout.ReadUInt16();
            HeadBMP.biBitCount      = dataout.ReadUInt16();
            HeadBMP.biCompression   = dataout.ReadUInt32();
            HeadBMP.biSizeImage     = dataout.ReadUInt32();
            HeadBMP.biXPelsPerMeter = dataout.ReadInt32();
            HeadBMP.biYPelsPerMeter = dataout.ReadInt32();
            HeadBMP.biClrUsed       = dataout.ReadUInt32();
            HeadBMP.biClrImportant  = dataout.ReadUInt32();
            int k = (int)(4 - (HeadBMP.biWidth * 3) % 4) % 4;

            matrix = new BMPRGB[Math.Abs(HeadBMP.biHeight), Math.Abs(HeadBMP.biWidth)];
            for (int i = 0; i < Math.Abs(HeadBMP.biHeight); i++)
            {
                for (int j = 0; j < Math.Abs(HeadBMP.biWidth); j++)
                {
                    matrix[i, j].rgbBlue  = dataout.ReadByte();
                    matrix[i, j].rgbGreen = dataout.ReadByte();
                    matrix[i, j].rgbRed   = dataout.ReadByte();
                }
                for (int i1 = 0; i1 < k; i1++)
                {
                    dataout.ReadByte();
                }
            }
        }
예제 #2
0
        void ReadBMP()
        {
            FileStream BMP = new FileStream(name, FileMode.Open);
            BinaryReader dataout = new BinaryReader(BMP);
            HeadBMP = new HeaderBMP();
            HeadBMP.bfType = dataout.ReadInt16();
            HeadBMP.bfSize = dataout.ReadUInt32();
            HeadBMP.Reserved1 = dataout.ReadInt16();
            HeadBMP.Reserved2 = dataout.ReadInt16();
            HeadBMP.bfOffBits = dataout.ReadInt32();

            HeadBMP.biSize = dataout.ReadUInt32();
            HeadBMP.biWidth = dataout.ReadInt32();
            HeadBMP.biHeight = dataout.ReadInt32();
            HeadBMP.biPlanes = dataout.ReadUInt16();
            HeadBMP.biBitCount = dataout.ReadUInt16();
            HeadBMP.biCompression = dataout.ReadUInt32();
            HeadBMP.biSizeImage = dataout.ReadUInt32();
            HeadBMP.biXPelsPerMeter = dataout.ReadInt32();
            HeadBMP.biYPelsPerMeter = dataout.ReadInt32();
            HeadBMP.biClrUsed = dataout.ReadUInt32();
            HeadBMP.biClrImportant = dataout.ReadUInt32();
            int k = (int)(4 - (HeadBMP.biWidth * 3) % 4) % 4;
            matrix = new BMPRGB[Math.Abs(HeadBMP.biHeight), Math.Abs(HeadBMP.biWidth)];
            for (int i = 0; i < Math.Abs(HeadBMP.biHeight); i++)
            {
                for (int j = 0; j < Math.Abs(HeadBMP.biWidth); j++)
                {
                    matrix[i, j].rgbBlue = dataout.ReadByte();
                    matrix[i, j].rgbGreen = dataout.ReadByte();
                    matrix[i, j].rgbRed = dataout.ReadByte();
                }
                for (int i1 = 0; i1 < k; i1++)
                    dataout.ReadByte();
            }
        }