3

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

I would like to rotate this to any angle.

Kevin
  • 9,309
  • 12
  • 44
  • 51
  • Clarify please, do you want to rotate the image 90/180/270 degrees or at any angle? – zxcat Sep 03 '09 at 19:24
  • 1
    Dupe of: http://stackoverflow.com/questions/875419/fast-method-to-rotate-image-in-net-compact-framework-in-c – ctacke Sep 10 '09 at 19:26

1 Answers1

2

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
  • 74,184
  • 40
  • 190
  • 334