Social Icons

Thursday, March 8, 2012

Drawing image using e.Graphics into Paint event of control

Following code will paint the image on Picture box paint Event....
 private void pictureBox2_Paint(object sender, PaintEventArgs e)
        {
            // Create image.
            Image newImage = pictureBox1.Image;

            // Create coordinates for upper-left corner of image.
            int x = 100;
            int y = 100;

            // Create rectangle for source image.
            Rectangle srcRect = new Rectangle(facex, facey, 150, 150);
            GraphicsUnit units = GraphicsUnit.Pixel;

            // Draw image to screen.
            if(newImage != null)
            e.Graphics.DrawImage(newImage, x, y, srcRect, units);
            
        }

No comments:

Post a Comment

 

Sample text

Sample Text