110,545
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication226
{
public partial class Form1 : Form
{
PictureBox PB = new PictureBox();
int Pos = 0;
int CurrentBmpIndex = 0;
Bitmap[] Bmps = new Bitmap[3];
public Form1()
{
InitializeComponent();
Bmps[0] = new Bitmap(100, 100);
using (Graphics G = Graphics.FromImage(Bmps[0]))
G.Clear(Color.Red);
Bmps[1] = new Bitmap(100, 100);
using (Graphics G = Graphics.FromImage(Bmps[1]))
G.Clear(Color.Green);
Bmps[2] = new Bitmap(100, 100);
using (Graphics G = Graphics.FromImage(Bmps[2]))
G.Clear(Color.Blue);
PB.Parent = this;
PB.Size = new Size(100, 100);
PB.Image = Bmps[0];
CurrentBmpIndex = 0;
Pos = 100;
Timer T = new Timer();
T.Interval = 10;
T.Tick += new EventHandler(T_Tick);
T.Enabled = true;
}
void T_Tick(object sender, EventArgs e)
{
if (++Pos > 100)
{
CurrentBmpIndex = (CurrentBmpIndex + 1) % 3;
Pos = 0;
}
Bitmap Temp =new Bitmap (100,100);
using (Graphics G = Graphics.FromImage(Temp))
{
G.DrawImage(PB.Image, new Rectangle(-1, 0, 100, 100));
G.DrawImage(Bmps[CurrentBmpIndex], new Rectangle(99, 0, 100, 100));
}
PB.Image = Temp;
}
}
}
this.pictureBox1.Location = new Point(this.pictureBox1.Location.X + 1, 17);