using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
namespace ff
{
/// <summary>
/// Form1에 대한 요약 설명입니다.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer timer1;
private System.Windows.Forms.Button button1;
private System.ComponentModel.IContainer components;
public Form1()
{
//
// Windows Form 디자이너 지원에 필요합니다.
//
InitializeComponent();
//
// TODO: InitializeComponent를 호출한 다음 생성자 코드를 추가합니다.
//
}
/// <summary>
/// 사용 중인 모든 리소스를 정리합니다.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form 디자이너에서 생성한 코드
/// <summary>
/// 디자이너 지원에 필요한 메서드입니다.
/// 이 메서드의 내용을 코드 편집기로 수정하지 마십시오.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.timer1 = new System.Windows.Forms.Timer(this.components);
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// timer1
//
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// button1
//
this.button1.Location = new System.Drawing.Point(256, 0);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(344, 277);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.Closed += new System.EventHandler(this.Form1_Closed);
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 해당 응용 프로그램의 주 진입점입니다.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
Image b1;
Image b2;
private void Form1_Load(object sender, System.EventArgs e)
{
b1 = new Bitmap("C:\\Documents and Settings\\won\\My Documents\\My Pictures\\10003307571.gif");
b2 = new Bitmap(b1.Width*100, b1.Height);
Graphics g = Graphics.FromImage(b2);
g.FillRectangle(new SolidBrush(BackColor), 0,0, b2.Width,b2.Height);
float[][] matrix = {
new float[]{1,0,0,0,0},
new float[]{0,1,0,0,0},
new float[]{0,0,1,0,0},
new float[]{0,0,0,0f,0},
new float[]{0,0,0,0,1}
};
for(int i=0; i<99; i++)
{
ColorMatrix colMatrix = new ColorMatrix(matrix);
ImageAttributes imgAtt = new ImageAttributes();
imgAtt.SetColorMatrices(colMatrix, colMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(b1, new Rectangle(i*b1.Width, 0, b1.Width, b1.Height), 0, 0, b1.Width, b1.Height,
GraphicsUnit.Pixel, imgAtt);
matrix[3][3]+=0.01f;
}
g.Dispose();
timer1.Interval = 300;
}
int p=0;
private void timer1_Tick(object sender, System.EventArgs e)
{
Graphics g = this.CreateGraphics();
g.DrawImage(b2, new Rectangle(0,0,b1.Width,b1.Height), p*b1.Width, 0, b1.Width, b1.Height, GraphicsUnit.Pixel);
g.Dispose();
p++;
}
bool timerState = false;
private void button1_Click(object sender, System.EventArgs e)
{
if(timerState)
{
timerState = false;
timer1.Stop();
}
else
{
timerState = true;
timer1.Start();
}
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawImage(b2, new Rectangle(0,0,b1.Width,b1.Height), p*b1.Width, 0, b1.Width, b1.Height, GraphicsUnit.Pixel);
}
private void Form1_Closed(object sender, System.EventArgs e)
{
b1.Dispose();
b2.Dispose();
}
}
}