利用picturebox控件动态显示图像
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
利用picturebox控件动态显示图像
(程序在最后)
using System;
using ;
using ponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using ;
namespace PictureBox控件
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Bitmap MyBitmap;
private void button1_Click(object sender, EventArgs e)
{
;
if ( == "")
return;
try
{
Bitmap SrcBitmap = new Bitmap(;
MyBitmap = new Bitmap(SrcBitmap, , ;
= MyBitmap;
}
catch (Exception Err)
{
MessageBox.Show(this, "打开图像文件出错!", "信息提示", MessageBoxButtons.OK, rmation);
}
}
private void button2_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
Bitmap bitmap = new Bitmap(iWidth, iHeight);
int x = 0;
while (x <= iWidth / 2)
{
for (int i = 0; i < iHeight - 1; i++)
{
bitmap.SetPixel(x, i, MyBitmap.GetPixel(x, i));
}
for (int i = 0; i <= iHeight - 1; i++)
{
bitmap.SetPixel(iWidth - x - 1, i, MyBitmap.GetPixel(iWidth - x - 1, i)); }
x++;
;
= bitmap;
}
}
private void button3_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
Bitmap bitmap = new Bitmap(iWidth, iHeight);
int x = 0;
while (x <= iHeight / 2)
{
for (int i = 0; i < iWidth - 1; i++)
{
bitmap.SetPixel(i, x, MyBitmap.GetPixel(i, x));
}
for (int i = 0; i <= iWidth - 1; i++)
{
bitmap.SetPixel(i, iHeight - x - 1, MyBitmap.GetPixel(i, iHeight - x - 1)); }
x++;
;
= bitmap;
}
}
private void button4_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
for (int y = 0; y <= iHeight; y++)
{
g.DrawImage(MyBitmap, 0, 0, iWidth, y);
}
}
private void button5_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
for (int y = 0; y <= iWidth ; y++)
{
g.DrawImage(MyBitmap, 0, 0, y,iWidth);
}
}
private void button9_Click(object sender, EventArgs e)
{
this.Close();
}
private void button6_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
for (int y=0; y <= iWidth / 2; y++)
{
Rectangle DestRect = new Rectangle(iWidth / 2 - y, 0, 2 * y, iHeight);
Rectangle SrcRect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height);
g.DrawImage(MyBitmap, DestRect, SrcRect, GraphicsUnit.Pixel);
}
}
private void button7_Click(object sender, EventArgs e)
{
int iWidth = ;
int iHeight = ;
Graphics g = ;
g.Clear(Color.Gray);
for (int y = -iWidth / 2; y <= iWidth / 2; y++)
{
Rectangle DestRect = new Rectangle( 0,iWidth / 2 - y, iHeight,2 * y );
Rectangle SrcRect = new Rectangle(0, 0, MyBitmap.Width, MyBitmap.Height);