【发布时间】:2009-08-10 00:25:16
【问题描述】:
Windows Mobile 编程中是否有任何机制来旋转位图?
我想把它旋转到任意角度。
【问题讨论】:
-
请澄清一下,您要将图像旋转 90/180/270 度还是任意角度?
标签: windows-mobile compact-framework directdraw
Windows Mobile 编程中是否有任何机制来旋转位图?
我想把它旋转到任意角度。
【问题讨论】:
标签: windows-mobile compact-framework directdraw
您必须自己在代码中执行此操作,因为 RotateTransform 在 CF 中不可用:
public Bitmap GetRotatedBitmap(Bitmap original)
{
Bitmap output = new Bitmap(original.Height, original.Width);
for (int x = 0; x < output.Width; x++)
{
for (int y = 0; y < output.Height; y++)
{
output.SetPixel(x, y, original.GetPixel(y, x));
}
}
return output;
}
SetPixel 和 GetPixel 慢得离谱;一种更快的方法是使用 LockBits 方法(关于 SO 的许多问题显示了如何使用它)。
【讨论】: