Public static bitmap rotateimage (image, float angle)
{
If (image = NULL)
Throw new argumentnullexception ("image ");
Float dx = image. width/2.0f;
Float DY = image. Height/2.0f;
Bitmap rotatedbmp = new Bitmap (image. Width, image. Height );
Rotatedbmp. setresolution (image. horizontalresolution, image. verticalresolution );
Graphics G = graphics. fromimage (rotatedbmp );
G. translatetransform (dx, Dy );
G. rotatetransform (angle );
G. translatetransform (-dx,-dy );
G. drawimage (image, new pointf (0, 0 ));
Return rotatedbmp;
}
Void tm_elapsed (Object sender, eventargs E)
{
If (isstart)
{
Angle + = 5;
If (angle >=359) angle = 0;
Rotateimage (pic1, properties. Resources. _ 1, angle );
}
}
private void rotateimage (picturebox Pb, image IMG, float angle)
{< br> If (IMG = NULL | Pb. image = NULL)
return;
image oldimage = Pb. image;
Pb. image = utilities. rotateimage (IMG, angle);
If (oldimage! = NULL)
{< br> oldimage. Dispose ();
}< BR >}