I have an image with two points, aligned something like this:
|----------------|
| |
| . |
| |
| . |
Performing a general 2D transformation involves solving a pair of eqautions with 6 unknowns.
'x = xA + yB + C
'y = xD + yE + D
Given 3 corresponding points, you will have 6 knowns and the system can be solved. You only have 4 points in this case, since you don't care about shear, but you could imagine introducing a 3rd point at 90 degrees to the line formed by the other two points. Creating a rotated image is then ( pseudo codedily ) just something like:
for ( y = 0; y < height; y++ )
for ( x = 0; x < width; x++ )
{
newx = x*A + y*B + C;
newy = x*D + y*D + E;
newimage(x,y ) = oldimage( newx, newy );
}
}
If performance is important, the multiplies in the inner loop can be optimised away by noting that y*B only changes in the outer look and that newx,newy change by constants A and D in the inner loop.