internal EMFSetPageTransform(int flags, byte[] RecordData)
        {
            MemoryStream _fs = null;
            BinaryReader _fr = null;
            try
            {
                _fs = new MemoryStream(BitConverter.GetBytes(flags));
                _fr = new BinaryReader(_fs);

                //PageUnit...
                UInt16 PageU = _fr.ReadByte();
                PageUnit = (Android.Util.ComplexUnitType)PageU;

                UInt16 RealFlags = _fr.ReadByte();
                //XXXXXAXX - if A = 1 the transform matrix is post-multiplied else pre-multiplied...
                //01234567
                postMultiplyTransform = ((RealFlags & (UInt16)Math.Pow(2, 5)) == Math.Pow(2, 5));
                PageScale = BitConverter.ToSingle(RecordData, 0);

            }
            finally
            {
                if (_fr != null)
                    _fr.Close();
                if (_fs != null)
                    _fs.Dispose();

            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts an unpacked complex data value holding a dimension to its final floating point value. The two parameters unit and value are as in TYPE_DIMENSION.
        /// </summary>
        /// <param name="unit"></param>
        /// <param name="value"></param>
        /// <param name="metrics"></param>
        /// <returns></returns>
        /// <remarks>
        /// This method is an extract of com.google.android/android/5.1.1_r1/android/util/TypedValue.java, for performance.
        /// See http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/util/TypedValue.java#339
        /// </remarks>
        public static double ApplyDimension(Android.Util.ComplexUnitType unit, double value)
        {
            switch (unit)
            {
            case Android.Util.ComplexUnitType.Px:
                return(value);

            case Android.Util.ComplexUnitType.Dip:
                return(value * _cachedDensity);

            case Android.Util.ComplexUnitType.Sp:
                return(value * _cachedScaledDensity);

            case Android.Util.ComplexUnitType.Pt:
                return(value * _cachedScaledXDpi * (1.0d / 72));

            case Android.Util.ComplexUnitType.In:
                return(value * _cachedScaledXDpi);

            case Android.Util.ComplexUnitType.Mm:
                return(value * _cachedScaledXDpi * (1.0d / 25.4f));
            }

            return(0);
        }
        internal EMFSetPageTransform(int flags, byte[] RecordData)
        {
            MemoryStream _fs = null;
            BinaryReader _fr = null;

            try
            {
                _fs = new MemoryStream(BitConverter.GetBytes(flags));
                _fr = new BinaryReader(_fs);

                //PageUnit...
                UInt16 PageU = _fr.ReadByte();
                PageUnit = (Android.Util.ComplexUnitType)PageU;

                UInt16 RealFlags = _fr.ReadByte();
                //XXXXXAXX - if A = 1 the transform matrix is post-multiplied else pre-multiplied...
                //01234567
                postMultiplyTransform = ((RealFlags & (UInt16)Math.Pow(2, 5)) == Math.Pow(2, 5));
                PageScale             = BitConverter.ToSingle(RecordData, 0);
            }
            finally
            {
                if (_fr != null)
                {
                    _fr.Close();
                }
                if (_fs != null)
                {
                    _fs.Dispose();
                }
            }
        }