Private void RotateTransform_Click (object sender, System. EventArgs e)
{
Graphics graphics = this. CreateGraphics ();
Graphics. Clear (Color. White );
// Load the image
Bitmap image = new Bitmap ("nemo.bmp ");
// Obtain the center of the current window
Rectangle rect = new Rectangle (0, 0, this. ClientSize. Width, this. ClientSize. Height );
PointF center = new PointF (rect. Width/2, rect. Height/2 );
Float offsetX = 0;
Float offsetY = 0;
OffsetX = center. X-image.Width/2;
OffsetY = center. Y-image.Height/2;
// Create an image display area: make the center of the image consistent with the center of the window
RectangleF picRect = new RectangleF (offsetX, offsetY, image. Width, image. Height );
PointF Pcenter = new PointF (picRect. X + picRect. Width/2,
PicRect. Y + picRect. Height/2 );
// Rotate the image around the center for one week
For (int I = 0; I <361; I + = 10)
{
// The drawing plane is rotated at the center of the image.
Graphics. TranslateTransform (Pcenter. X, Pcenter. Y );
Graphics. RotateTransform (I );
// Restore the horizontal and vertical translation of the drawing plane
Graphics. TranslateTransform (-Pcenter. X,-Pcenter. Y );
// Draw the image and delay it
Graphics. DrawImage (image, picRect );
Thread. Sleep (100 );
// Reset all transformations of the drawing plane
Graphics. ResetTransform ();
}
}