How to rotate a bitmap with GDI+

How to rotate a bitmap with GDI+

Post by John » Thu, 06 Sep 2007 17:26:54


Hello,
do someone has a sample code that show how to rotate a bitmap under GDI+ ?

Thanks

John
 
 
 

How to rotate a bitmap with GDI+

Post by Shin » Thu, 06 Sep 2007 17:59:33


Hi John,

Try the following piece of code.

*****************************************
graphics := TGPGraphics.Create(DC);
Image:= TGPImage.Create('..\GrapeBunch.bmp');
LMatrix:= TGPMatrix.Create(1, 0, 0, 1,100, 200); //Change the X and
Y //coordinates with respect to <'le of rotation.
graphics.SetTransform(LMatrix);
graphics.RotateTransform(270); //Pass the angle of rotation
graphics.DrawImage(Image,0,0,Image.GetWidth,Image.GetHeight);
Image.Free;
graphics.Free;
*******************************************

Hope this will help you. :-)
Hey
Programmers never die: They just GOSUB without RETURN...... So keep
going...... ;-)

Regards,
Shine

 
 
 

How to rotate a bitmap with GDI+

Post by Pete » Thu, 06 Sep 2007 18:17:23


gr:=TGPGraphics.Create(DC);
Image:= TGPImage.Create('Image1.bmp');
.
.
gr.RotateTransform(30);//rotate 30 degrees
gr.DrawImage(image, x, y);//draw image at x,y

There are several overloaded version of DrawImage(), one of which will
allow you to scale and/or skew the image

http://www.yqcomputer.com/

Pete