gpt4 book ai didi

c# - 如何在没有翻译的情况下通过 pdfsharp 绘制图像?

转载 作者:太空宇宙 更新时间:2023-11-03 10:46:28 26 4
gpt4 key购买 nike

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

这是我试过的:

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

谢谢!

最佳答案

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

传递给 DrawImage 的坐标必须反射(reflect)变换。

另见:
http://pdfsharp.net/wiki/Graphics-sample.ashx#Draw_an_image_transformed_22

关于c# - 如何在没有翻译的情况下通过 pdfsharp 绘制图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23190497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com