0

actually I try to learn to program with C# and with Windows Form.

For rotating pixel of an image there are two possibilities.

  1. Rotating every pixel around the centre by using formula for rotating tranformation. (sounds clear for me)

  2. Normally I read in row by row of an image with 256x256 pixels for example with:

            for (int y = 1; y < 256; y++) // Heigth
            {
            for (int x = 1; x < 256; x++) //Width
            {
                Color pixelcolor = bitmap.GetPixel(x, y);
                .....bitmap.SetPixel(x, y, pixelcolor);
            }
            }
    

    I would like to read just in my "example" above row by row but with an angle. But how would it be if the rotation is for example be 14 degree? for 90,180,270 degree I would be able to improvise something.

Thanks for trying to help me!

KaidoSama
  • 1
  • 2
  • [This](https://stackoverflow.com/a/58444045/10216583) might help if you mean rotating an image. Its a VB.NET though. Not big deal. Page me if you need a hand to C# it. –  May 03 '20 at 15:09
  • 1
    rotation on a pixel by pixel basis is not a good idea: It will be slow and also tends to create gaps. Instead draw the whole image with a rotated Graphics object. [Example](https://stackoverflow.com/questions/26525965/rotate-a-graphics-bitmap-at-its-center/26527737?r=SearchResults&s=13|25.9613#26527737) – TaW May 03 '20 at 15:13
  • - If you insist on your way you will need to do it in reverse: for each pixel (row/column) in the target bitmap find the color in the source! - You could write a rotate function and maybe use a [Matrix](https://stackoverflow.com/questions/49885758/how-can-i-rotate-a-rectangle-using-a-matrix-and-get-the-modified-rectangle/49886367#49886367) - But, as I wrote: It will be painfully slow. – TaW May 03 '20 at 15:17
  • I rotated every pixel in my first version of program, but it was very slow (I work with a set of pixels). I will try the solution steps! Thanks! – KaidoSama May 03 '20 at 16:47

0 Answers0