C # picture animation effects (rotate 360 degrees)

  Private  void the Button1_Click ( Object SENDER, EventArgs E) 
        { 
         
            
            Graphics Graphics = the this .CreateGraphics (); 
            graphics.Clear (Color.White); 

            // charged image resources 

            // Bitmap Bitmap Image new new = (WindowsFormsApplication1.Properties.Resources.image_101 ); 
            Bitmap Image = new new Bitmap (HZH_Controls.Properties.Resources.alarm); 

            // get the current window is the center point of 

            the Rectangle RECT = new new the Rectangle ( 0 , 0 , the this .ClientSize.Width, the this.ClientSize.Height);
            Center of PointF = new new of PointF (rect.width / 2 , rect.height / 2 ); 

            a float offsetX = 0 ;
             a float offsetY = 0 ; 
            offsetX = center.X - image.width / 2 ; 
            offsetY = center.Y - image.height / 2 ;
             // constructor picture display area: the central point so that the center point of the picture window of the same 
            RectangleF picRect = new new RectangleF (offsetX, offsetY, image.width, image.height); 
            array of PointF Pcenter = new new array of PointF (picRect.X + picRect.Width /2 , 
                picRect.Y + picRect.Height / 2 ); 
            Color C = Color.FromArgb ( 200 is , 200 is , 200 is ); 


            // make one revolution around the center of the picture 
            for ( int I = 360 ; I> 0 ; I - = 10 ) 
            { 
                // the drawing image plane center point of rotation 
                graphics.TranslateTransform (Pcenter.X, Pcenter.Y); 


                graphics.RotateTransform (I); 
                // restore the translational plane of the drawing in the horizontal and vertical directions 
                graphics.TranslateTransform (-Pcenter .X, - Pcenter.Y);
                // Draw image and delay 
                Graphics.DrawImage (Image, picRect); 
                the Thread.Sleep ( 100 ); 
                graphics.Clear (C); 

                // reset all transform plane of the drawing 
                graphics.ResetTransform (); 
            } 
        }

 

Guess you like

Origin www.cnblogs.com/topsyuan/p/11589030.html