public override void Read(BinaryReader reader)
        {
            bool isWithoutBitmap = (this.RecordSize == 24);

            this.RasterOperation = (TernaryRasterOperation)reader.ReadUInt32();

            if (!isWithoutBitmap)
            {
                this.SrcHeight = reader.ReadInt16();
                this.SrcWidth  = reader.ReadInt16();
            }

            this.YSrc = reader.ReadInt16();
            this.XSrc = reader.ReadInt16();

            if (isWithoutBitmap)
            {
                short dummy = reader.ReadInt16();
            }

            this.DestHeight = reader.ReadInt16();
            this.DestWidth  = reader.ReadInt16();
            this.YDest      = reader.ReadInt16();
            this.XDest      = reader.ReadInt16();

            if (!isWithoutBitmap)
            {
                this.Target = reader.ReadWmfObject <DeviceIndependentBitmap>();
            }
        }
 public override void Read(BinaryReader reader)
 {
     this.ColorUsage = (ColorUsage)reader.ReadUInt16();
     this.ScanCount  = reader.ReadUInt16();
     this.StartScan  = reader.ReadUInt16();
     this.YDIB       = reader.ReadUInt16();
     this.XDIB       = reader.ReadUInt16();
     this.Height     = reader.ReadUInt16();
     this.Width      = reader.ReadUInt16();
     this.YDest      = reader.ReadUInt16();
     this.XDest      = reader.ReadUInt16();
     this.DIB        = reader.ReadWmfObject <DeviceIndependentBitmap>();
 }
Exemple #3
0
        /// <summary>
        ///   An existing bitmap file.
        /// </summary>
        /// <param name = "filename">A file in a .bmp format.</param>
        public BitmapFile(string filename)
        {
            var data = File.ReadAllBytes(filename);

            var pFileHeaderData = Marshal.AllocHGlobal(Marshal.SizeOf(_header));
            try {
                Marshal.Copy(data, 0, pFileHeaderData, Marshal.SizeOf(_header));
                _header = (BitmapFileHeader) Marshal.PtrToStructure(pFileHeaderData, typeof (BitmapFileHeader));
            }
            finally {
                Marshal.FreeHGlobal(pFileHeaderData);
            }

            var size = data.Length - Marshal.SizeOf(_header);
            var bitmapData = new byte[size];
            Buffer.BlockCopy(data, Marshal.SizeOf(_header), bitmapData, 0, size);
            _bitmap = new DeviceIndependentBitmap(bitmapData);
        }
Exemple #4
0
 /// <summary>
 ///   Read the resource.
 /// </summary>
 /// <param name = "hModule">Module handle.</param>
 /// <param name = "lpRes">Pointer to the beginning of a resource.</param>
 /// <returns>Pointer to the end of the resource.</returns>
 internal override IntPtr Read(IntPtr hModule, IntPtr lpRes)
 {
     var data = new byte[_size];
     Marshal.Copy(lpRes, data, 0, data.Length);
     _bitmap = new DeviceIndependentBitmap(data);
     return new IntPtr(lpRes.ToInt32() + _size);
 }
 public override void Read(BinaryReader reader)
 {
     this.Style      = (BrushStyle)reader.ReadUInt16();
     this.ColorUsage = (ColorUsage)reader.ReadUInt16();
     this.Target     = reader.ReadWmfObject <DeviceIndependentBitmap>();        //TODO: How many bytes?
 }