3

Windows Mobile 编程中是否有任何机制来旋转位图?

我想把它旋转到任何角度。

4

1 回答 1

2

您必须自己在代码中执行此操作,因为 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 的许多问题显示了如何使用它)。

于 2009-08-10T01:01:34.730 回答