This is really more analytical geometry than it is trig.
I rotated about (0,0), but you wanted to rotate about the center.
So let's say that you have a 16x16 grid with the corner points at 0,0, 0,15, 15,0, and 15,15 and you want to rotate it through an angle R.
Let's walk through it:
First, to rotate a vector about (0,0), you need:
[itex]X_{new} = cos(R)X_{old} - sin(R)Y_{old}[/itex]
and
[itex]Y_{new} = cos(R)Y_{old} + sin(R)X_{old}[/itex]
Or, if you already know what [itex]X_{new},Y_{new}[/itex] is, but you need to know where it came from, then you would use these equations:
[itex]X_{old} = cos(R)X_{new} + sin(R)Y_{new}[/itex]
[itex]Y_{old} = cos(R)Y_{new} - sin(R)X_{new}[/itex]
But you want to rotate about the center of the square, at coordinates 7.5, 7.5. So we would use this:
[itex]X_{old}-7.5 = cos(R)(X_{new}-7.5) + sin(R)(Y_{new}-7.5)[/itex]
[itex]Y_{old}-7.5 = cos(R)(Y_{new}-7.5) - sin(R)(X_{new}-7.5)[/itex]
or
[itex]X_{old} = cos(R)X_{new} + sin(R)Y_{new} + 7.5 - 7.5cos(R) - 7.5sin(R)[/itex]
[itex]Y_{old} = cos(R)Y_{new} - sin(R)X_{new} + 7.5 -7.5cos(R) + 7.5sin(R)[/itex]
or
[itex]X_{old} = cos(R)X_{new} + sin(R)Y_{new} + 7.5(1-cos(R)-sin(R))[/itex]
[itex]Y_{old} = cos(R)Y_{new} - sin(R)X_{new} + 7.5(1-cos(R)+sin(R))[/itex]
Then, by table lookup, you would find the sin and cosine of the angle of rotation. In my example, I used 40 degrees, but any rotation angle can be selected.
As I described before, these would be fixed point values with enough places to the right on the binary point to produce the precision you needed.
C = sine-table-lookup(90°-R)
S = sine-table-lookup(R)
Then compute those two offset values (keeping fixed point arithmetic):
[itex]X_o = 7.5(1-C-S)[/itex]
[itex]Y_o = 7.5(1-C+S)[/itex]
Now loop through all pixels in your destination pixel array [itex]X_{new}=0 to 15[/itex] and [itex]X_{new}=0 to 15[/itex]
For each of those 256 coordinate pairs compute the location where the pixel value will come from:
[itex]X_{old} = C\times X_{new} + S\times Y_{new} + X_o[/itex]
[itex]Y_{old} = C\times Y_{new} - S\times X_{new} + Y_o[/itex]
Finally, copy the pixel data:
If [itex]0\le X_{old}\le 15[/itex] and [itex]0\le Y_{old}\le 15[/itex] then:
[itex]Image_{new}[X_{new},Y_{new}]=Image_{old}[X_{old},Y_{old}][/itex]
else:
[itex]Image_{new}[X_{new},Y_{new}]=[/itex]background_color