简体   繁体   中英

How can I draw image by pdfsharp without translation?

I'm trying to draw a image to pdf page with rotate transform. The problem is when I draw it without any transform the coordinate is right so the image is putted correctly(here is x = 0 and y = 0). But when I try to rotate(90Deg) the image before drawing, event if I set new coordinate, the image is not putted at the point that I want to.

Here's I tried:

 gp.TranslateTransform(modelWidth / 2, modelHeight / 2);

            if (angle > 0)
            {
                gp.RotateTransform(angle);
            }

            gp.TranslateTransform(-modelWidth / 2, -modelHeight / 2);

            /*----------------------------------------------------------------*/
            gp.DrawImage(xImg, new Drawing.Point(0, 0));

Thanks!

You don't rotate the Image, you rotate the graphics context.

The co-ordinates passed to DrawImage must reflect the transformations.

See also:
http://pdfsharp.net/wiki/Graphics-sample.ashx#Draw_an_image_transformed_22

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM