
前田稔(Maeda Minoru)の超初心者のプログラム入門
![]()
![]()
/***************************************/
/*★ 画像描画のエトセトラ 前田 稔 ★*/
/***************************************/
using System;
using System.Drawing;
using System.Windows.Forms;
public class MyForm : Form
{
string file = @"c:\data\test\kishi.gif";
public MyForm()
{
Text = "Image etc";
BackColor = SystemColors.AppWorkspace;
Width = 420;
Height = 250;
Paint += new PaintEventHandler(MyHandler);
}
private void MyHandler(object sender, PaintEventArgs e)
{
Bitmap bmpw = new Bitmap(file);
Bitmap bmp = new Bitmap(bmpw,100,100);
Graphics g = e.Graphics;
g.DrawImage(bmp,0,0); //描画①
g.DrawImage(bmp, new Rectangle(100,0,50,50)); //描画②
g.DrawImage(bmp, 300, 0, -100, 100); //描画③
g.DrawImage(bmp, 300, 100, 100, -100); //描画④
}
}
class image01
{
public static void Main()
{
MyForm mf = new MyForm();
Application.Run(mf);
}
}
|
Bitmap bmpw = new Bitmap(file);
Bitmap bmp = new Bitmap(bmpw,100,100);
|
| g.DrawImage(bmp, new Rectangle(100,0,50,50)); //描画② |
| g.DrawImage(bmp, 300, 0, -100, 100); //描画③ |
| g.DrawImage(bmp, 300, 100, 100, -100); //描画④ |
![]()
Bitmap bmp = new Bitmap(bmpw,100,100);
・・・
bmp.RotateFlip(RotateFlipType.Rotate90FlipNone);
g.DrawImage(bmp,0,100); //描画⑤
|
bmp.RotateFlip(RotateFlipType.Rotate90FlipX);
g.DrawImage(bmp,100,100); //描画⑥
|
Point[] pnts = new Point[]
{ new Point(180, 100), new Point(360, 120), new Point(240, 200) };
|
| g.DrawImage(bmp, pnts); //描画⑦ |
![]()