views:

636

answers:

2

Are there any mechanism within Windows Mobile programming to rotate a Bitmap?

I would like to rotate this to any angle.

+2  A: 

You have to do this yourself in code, since RotateTransform isn't available in 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 and GetPixel are absurdly slow; a faster way to do this is with the LockBits method (there are a number of questions on SO that show how to use this).

MusiGenesis
+1 for the logo..Great answser too.
Daniel M
A: 

thanks,but it works too slowly when the pic is some large.

wenmin.h
Use the LockBits method I mentioned and you'll speed things up by a couple of orders of magnitude. SetPixel and GetPixel are beyond slow.
MusiGenesis