【问题标题】:How can I draw image by pdfsharp without translation?如何在不翻译的情况下通过 pdfsharp 绘制图像?
【发布时间】:2014-04-21 03:45:20
【问题描述】:

我正在尝试使用旋转变换将图像绘制到 pdf 页面。问题是当我在没有任何变换的情况下绘制它时,坐标是正确的,因此图像被正确放置(这里是 x = 0 和 y = 0)。但是当我在绘制之前尝试旋转(90Deg)图像时,如果我设置了新坐标,图像不会放在我想要的位置。

我试过了:

 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));

谢谢!

【问题讨论】:

    标签: c# pdfsharp


    【解决方案1】:

    您不旋转图像,而是旋转图形上下文。

    传递给 DrawImage 的坐标必须反映变换。

    另请参阅:
    http://pdfsharp.net/wiki/Graphics-sample.ashx#Draw_an_image_transformed_22

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多