GetFrame() public method

Gets the metafile frame in pixels.

The frame is the metafile size set by the author.

This member function is similar to Metafile.GetBounds().

public GetFrame ( ) : RectangleF
return RectangleF
示例#1
0
        public void ToByteArray_CorrectFrame()
        {
            Bill bill = SampleData.CreateExample4();

            bill.Format.OutputSize      = OutputSize.A4PortraitSheet;
            using MetafileCanvas canvas = new MetafileCanvas(QRBill.A4PortraitWidth, QRBill.A4PortraitHeight, "Helvetica, Arial, \"Liberation Sans\"");
            QRBill.Draw(bill, canvas);

            EmfMetaInfo metaInfo = new EmfMetaInfo(canvas.ToByteArray());

            Assert.Equal(257, metaInfo.NumRecords);

            var scale = metaInfo.Dpi / 25.4f;
            // Returns the frame in pixels
            var frame = metaInfo.GetFrame();

            Assert.Equal(0, frame.Left);
            Assert.Equal(0, frame.Top);
            int expectedWidth = (int)(QRBill.A4PortraitWidth * scale);

            Assert.InRange(frame.Right, expectedWidth - 2, expectedWidth + 2);
            int expectedHeight = (int)(QRBill.A4PortraitHeight * scale);

            Assert.InRange(frame.Bottom, expectedHeight - 2, expectedHeight + 2);
        }