为什么Graphics.RotateTransform()不能被应用? [英] Why might Graphics.RotateTransform() not be applied?

查看:443
本文介绍了为什么Graphics.RotateTransform()不能被应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下功能:

pre $ static private Image CropRotate(Image wholeImage,Rectangle cropArea)
{
位图裁剪=新位图(cropArea.Width,cropArea.Height);

using(Graphics g = Graphics.FromImage(cropped))
{
g.DrawImage(wholeImage,new Rectangle(0,0,cropArea.Width,cropArea.Height) ,cropArea,GraphicsUnit.Pixel);
g.RotateTransform(180f);
}
返回裁剪为图片;
}

它应该裁剪图像,然后旋转最终的子图像。为什么 RotateTransform()没有被应用?



为什么< >

解决方案

您是否曾尝试将 RotateTransform()放在的DrawImage()
msdn页面上的示例显示正在应用的转换在任何绘图完成之前。


I have the following function:

static private Image CropRotate(Image wholeImage, Rectangle cropArea)
{
    Bitmap cropped = new Bitmap(cropArea.Width, cropArea.Height);

    using(Graphics g = Graphics.FromImage(cropped))
    {
        g.DrawImage(wholeImage, new Rectangle(0, 0, cropArea.Width, cropArea.Height), cropArea, GraphicsUnit.Pixel);
        g.RotateTransform(180f);
    }
    return cropped as Image;
}

It's supposed to crop an image, then rotate the resulting sub-image. In actuality though, it only performs the crop.

Why is RotateTransform() not being applied?

解决方案

Have you tried putting the RotateTransform() before the DrawImage()? The example on the msdn page shows the transformation being applied before any drawing is done.

这篇关于为什么Graphics.RotateTransform()不能被应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆