为什么Graphics.RotateTransform()不能被应用? [英] Why might Graphics.RotateTransform() not be applied?
问题描述
我有以下功能:
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屋!