Esempio n. 1
0
 private static EMFFont Process(byte[] RecordData)
 {
     //put the Data into a stream and use a binary reader to read the data
     MemoryStream _ms = null;
     BinaryReader _br = null;
     try
     {
         _ms = new MemoryStream(RecordData);
         _br = new BinaryReader(_ms);
         UInt32 Version = _br.ReadUInt32();
         Single EmSize = _br.ReadSingle();
         UInt32 SizeUnit = _br.ReadUInt32();
         Int32 FontStyleFlags = _br.ReadInt32();
         _br.ReadUInt32();
         UInt32 NameLength = _br.ReadUInt32();
         char[] FontFamily = new char[NameLength]; 
         System.Text.UnicodeEncoding d = new System.Text.UnicodeEncoding();
         d.GetChars(_br.ReadBytes((int)NameLength * 2),0,(int)NameLength * 2,FontFamily,0);                
         Font aFont = new Font(new String(FontFamily), EmSize, (FontStyle)FontStyleFlags, (GraphicsUnit)SizeUnit);
         EMFFont ThisFont = new EMFFont();
         ThisFont.myFont = aFont;
         return ThisFont;
     }
     finally
     {
         if (_br != null)
             _br.Close();               
         if (_ms != null)
             _ms.Dispose();            
     }
 }
Esempio n. 2
0
        private static EMFFont Process(byte[] RecordData)
        {
            //put the Data into a stream and use a binary reader to read the data
            MemoryStream _ms = null;
            BinaryReader _br = null;

            try
            {
                _ms = new MemoryStream(RecordData);
                _br = new BinaryReader(_ms);
                UInt32 Version        = _br.ReadUInt32();
                Single EmSize         = _br.ReadSingle();
                UInt32 SizeUnit       = _br.ReadUInt32();
                Int32  FontStyleFlags = _br.ReadInt32();
                _br.ReadUInt32();
                UInt32 NameLength             = _br.ReadUInt32();
                char[] FontFamily             = new char[NameLength];
                System.Text.UnicodeEncoding d = new System.Text.UnicodeEncoding();
                d.GetChars(_br.ReadBytes((int)NameLength * 2), 0, (int)NameLength * 2, FontFamily, 0);
                Font    aFont    = new Font(new String(FontFamily), EmSize, (FontStyle)FontStyleFlags, (GraphicsUnit)SizeUnit);
                EMFFont ThisFont = new EMFFont();
                ThisFont.myFont = aFont;
                return(ThisFont);
            }
            finally
            {
                if (_br != null)
                {
                    _br.Close();
                }
                if (_ms != null)
                {
                    _ms.Dispose();
                }
            }
        }
Esempio n. 3
0
        public List <PageItem> Process(int Flags, byte[] RecordData)
        {
            MemoryStream _ms = null;
            BinaryReader _br = null;
            MemoryStream _fs = null;
            BinaryReader _fr = null;

            try
            {
                _fs = new MemoryStream(BitConverter.GetBytes(Flags));
                _fr = new BinaryReader(_fs);
                //Byte 1 will be ObjectID - a font in the object table
                byte ObjectID = _fr.ReadByte();
                //Byte 2 is the real flags
                byte RealFlags = _fr.ReadByte();
                // 0 1 2 3 4 5 6 7
                // X X X X X X X S
                // if S = type of brush - if S then ARGB, else a brush object in object table

                _ms = new MemoryStream(RecordData);
                _br = new BinaryReader(_ms);
                bool  BrushIsARGB = ((RealFlags & (int)Math.Pow(2, 7)) == (int)Math.Pow(2, 7));
                Brush b;
                if (BrushIsARGB)
                {
                    byte A, R, G, B;
                    B = _br.ReadByte();
                    G = _br.ReadByte();
                    R = _br.ReadByte();
                    A = _br.ReadByte();
                    b = new SolidBrush(Color.FromArgb(A, R, G, B));
                }
                else
                {
                    UInt32   BrushID = _br.ReadUInt32();
                    EMFBrush EMFb    = (EMFBrush)ObjectTable[(byte)BrushID];
                    b = EMFb.myBrush;
                }

                UInt32 FormatID     = _br.ReadUInt32(); // Index of Optional stringFormatobject in Object Table...
                UInt32 StringLength = _br.ReadUInt32();
                //bounding of string...
                Single recX      = _br.ReadSingle();
                Single recY      = _br.ReadSingle();
                Single recWidth  = _br.ReadSingle();
                Single recHeight = _br.ReadSingle();
                //Array of Chars...
                char[] StringData             = new char[StringLength];
                System.Text.UnicodeEncoding d = new System.Text.UnicodeEncoding();
                d.GetChars(_br.ReadBytes((int)StringLength * 2), 0, (int)StringLength * 2, StringData, 0);
                EMFFont      EF = (EMFFont)ObjectTable[(byte)ObjectID];
                Font         f  = EF.myFont;
                StringFormat sf;
                if (ObjectTable.Contains((byte)FormatID))
                {
                    EMFStringFormat ESF = (EMFStringFormat)ObjectTable[(byte)FormatID];
                    sf = ESF.myStringFormat;
                }
                else
                {
                    sf = new StringFormat();
                }

                DoInstructions(f, sf, b, recX, recY, recWidth, recHeight, new String(StringData));
                return(items);
            }
            finally
            {
                if (_br != null)
                {
                    _br.Close();
                }
                if (_ms != null)
                {
                    _ms.Dispose();
                }
                if (_fr != null)
                {
                    _fr.Close();
                }
                if (_fs != null)
                {
                    _fs.Dispose();
                }
            }
        }
Esempio n. 4
0
        internal static EMFRecordObject getObject(int flags, byte[] RecordData)
        {
            MemoryStream _ms = null;
            BinaryReader _br = null;

            try
            {
                //Put the Flags into a stream and then use a binary Reader to read the Flags
                _ms = new MemoryStream(BitConverter.GetBytes(flags));
                _br = new BinaryReader(_ms);
                //ObjectID is least significant byte (which will be the first byte in the byte array due to Little Endian)
                byte Objectid = _br.ReadByte();
                //Object Type next...
                byte ObjectTyp = _br.ReadByte();
                //Don't know what to do if this object continues on the next one!
                bool ContinuesOnNextObject = ((ObjectTyp & 128) == 128);
                if (ContinuesOnNextObject)
                {
                    ObjectTyp ^= 128;
                }

                switch ((UInt16)ObjectTyp)
                {
                case (UInt16)EmfObjectType.invalid:
                    break;

                case (UInt16)EmfObjectType.brush:
                    EMFBrush Obrush = EMFBrush.getEMFBrush(RecordData);
                    Obrush.ObjectID = Objectid;
                    return(Obrush);

                case (UInt16)EmfObjectType.pen:
                    EMFPen OPen = EMFPen.getEMFPen(RecordData);
                    OPen.ObjectID = Objectid;
                    return(OPen);

                case (UInt16)EmfObjectType.path:
                    break;

                case (UInt16)EmfObjectType.region:
                    break;

                case (UInt16)EmfObjectType.image:
                    break;

                case (UInt16)EmfObjectType.font:
                    EMFFont OFont = EMFFont.getEMFFont(RecordData);
                    OFont.ObjectID = Objectid;
                    return(OFont);

                case (UInt16)EmfObjectType.stringformat:
                    EMFStringFormat Ostringformat = EMFStringFormat.getEMFStringFormat(RecordData);
                    Ostringformat.ObjectID = Objectid;
                    return(Ostringformat);

                case (UInt16)EmfObjectType.ImageAttributes:
                    break;

                case (UInt16)EmfObjectType.CustomLineType:
                    break;
                }
                return(null);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                if (_br != null)
                {
                    _br.Close();
                }
                if (_ms != null)
                {
                    _ms.Dispose();
                }
            }
        }