C# CopyFromScreen Animation
Filed in C#, Code Snippets on Oct.07, 2009
Here is a code snippet:
private void Form1_Load(object sender, EventArgs e) { this.Show(); Graphics myGraphics = this.CreateGraphics(); Image memoryImage = new Bitmap(200, 180, myGraphics); Graphics memoryGraphics = Graphics.FromImage(memoryImage); int x = 0; int y = 0; int v = 1; int w = 1; while (run) { x += v; y += w; if (x >= Screen.PrimaryScreen.WorkingArea.Width - 200 || x <= 0) v = -v; if (y >= Screen.PrimaryScreen.WorkingArea.Height - 180 || y <= 0) w = -w; memoryGraphics.CopyFromScreen(x, y, 0, 0, new Size(200, 180)); LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, 200, 180), Color.Transparent, Color.Gold, LinearGradientMode.ForwardDiagonal); memoryGraphics.FillRectangle(brush, new Rectangle(0, 0, 200, 180)); Application.DoEvents(); pictureBox1.Image = memoryImage; } }
Related posts:























Leave a Reply
You must be logged in to post a comment.