I am trying to write an algorithm to rotate a bitmap image of $n$ by $n$ size by an angle $\alpha$.
I know that I have to find a rotation matrix, then perform matrix multiplication of the rotation matrix by the image matrix data input.
I know that the $2\times 2$ rotation matrix is
$$T_\alpha=\left(\begin{array}{cc}\cos\alpha & -\sin\alpha \\ \sin \alpha & \cos \alpha \end{array}\right)$$
However, I am not sure how to find the appropriate $n \times n$ matrix.
Let $w, h$ be the width & height of the image in pixels, but promote them to floats for further computation.
You take the image center $c = (w, h)/2$
Then treat each pixel coordinate as a coordinate with origin at $c$. In other words subtract $c$ from each pixel coordinate $v' = (x,y) - c$.
Now as you have the rotation matrix, you need only convert $v'$ to a column vector and multiply with $v'$ on the right.
If your rotation matrix was constructed using the right hand rule. And your image space (in whatever coding environment) originally started with $(0,0)$ at the bottom left, then this will rotate the image around its center $\alpha$ radians counter clockwise.
As far as final image quality though, this is probably bad once you discretize into a new image. This is why you should use something already coded.