【问题标题】:Rotate an Image in Windows Mobile Programming在 Windows Mobile 编程中旋转图像
【发布时间】:2009-08-10 00:25:16
【问题描述】:

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

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

【问题讨论】:

标签: windows-mobile compact-framework directdraw


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-04-02
    • 1970-01-01
    • 2011-01-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-25
    • 2010-10-19
    • 2014-12-09
    相关资源
    最近更新 更多