So I was working on my engine a bit and unfortunately made a call to Image.Rotate(Deg: Int64) and its not that it does not work, it just does not work as you would expect it to...

To rotate the texture I am using:
Code:
procedure Image.Rotate(Deg: Int64);
begin
    glPushAttrib(GL_TRANSFORM_BIT);
    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    glBindTexture( GL_TEXTURE_2D, texture);
    glTranslatef(0.5, 0.5, 0);
    glRotatef(Deg, 0, 0, 1);
    glTranslatef(-0.5, -0.5, 0);
    glPopAttrib();
end;
Which as far as I am concerned is pretty simple and straight forward, and drawing also follows suit with:

Code:
procedure Image.Draw(X,Y: Int64);
var
    VxR: array [1..2] of LongInt;
    VyR: array [1..2] of LongInt;
    
    PxR: array [1..2] of Int64;
    PyR: array [1..2] of Int64;
    
begin
    VxR[1] := 0;
    VxR[2] := XScale;
    VyR[1] := 0;
    VyR[2] := YScale;
    
    PxR[1] := X;
    PxR[2] := X + GlWidth;
    PyR[1] := Y;
    PyR[2] := Y + GlHeight;

    glBindTexture( GL_TEXTURE_2D, texture );

    glBegin( GL_QUADS );
    glTexCoord2i( VxR[1], VyR[2] );
    glVertex3f( PxR[1], PyR[2], 0. );

    glTexCoord2i( VxR[2], VyR[2] );
    glVertex3f( PxR[2], PyR[2], 0. );

    glTexCoord2i( VxR[2], VyR[1] );
    glVertex3f( PxR[2], PyR[1], 0. );

    glTexCoord2i( VxR[1], VyR[1] );
    glVertex3f( PxR[1], PyR[1], 0. );
    glEnd();
end;
(please don't ask about variable names. This is really old code from me )

and I get this 'interesting' result:
Rotation Glitch.jpg
(yes, its an alchemy logo because its the only small png file I had off hand XD )

Is there any way to get the new X, Y, Height and Width co-ordinates without drawing that garbage data round the image?

cheers,
code_glitch.

ps: sorry for the long post.