示例#1
0
        /// <summary>
        /// Draws an image transformed.
        /// </summary>
        void DrawImageSheared(XGraphics gfx, int number)
        {
            BeginBox(gfx, number, "DrawImage (sheared)");

            XImage image = XImage.FromFile(jpegSamplePath);

            const double dx = 250, dy = 140;

            //XMatrix matrix = gfx.Transform;
            //matrix.TranslatePrepend(dx / 2, dy / 2);
            //matrix.ScalePrepend(-0.7, 0.7);
            //matrix.ShearPrepend(-0.4, -0.3);
            //matrix.TranslatePrepend(-dx / 2, -dy / 2);
            //gfx.Transform = matrix;

            gfx.TranslateTransform(dx / 2, dy / 2);
            gfx.ScaleTransform(-0.7, 0.7);
            gfx.ShearTransform(-0.4, -0.3);
            gfx.TranslateTransform(-dx / 2, -dy / 2);

            double width  = image.PixelWidth * 72 / image.HorizontalResolution;
            double height = image.PixelHeight * 72 / image.HorizontalResolution;

            gfx.DrawImage(image, (dx - width) / 2, 0, width, height);

            EndBox(gfx);
        }
示例#2
0
        private void DrawImageSheared(XGraphics gfx, int number)
        {
            base.BeginBox(gfx, number, "DrawImage (sheared)");
            XImage xImage = XImage.FromFile("../../../../../../dev/XGraphicsLab/images/Z3.jpg");

            gfx.TranslateTransform(125.0, 70.0);
            gfx.ScaleTransform(-0.7, 0.7);
            gfx.ShearTransform(-0.4, -0.3);
            gfx.TranslateTransform(-125.0, -70.0);
            double num    = (double)(xImage.PixelWidth * 72) / xImage.HorizontalResolution;
            double height = (double)(xImage.PixelHeight * 72) / xImage.HorizontalResolution;

            gfx.DrawImage(xImage, (250.0 - num) / 2.0, 0.0, num, height);
            base.EndBox(gfx);
        }