C#图片浏览器

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
2.4幻灯片播放
private void timer1_Tick(object sender, EventArgs e) //播放时展示下一张 { if (index < arrPath.Length - 1) { pictureBox1.Load(arrPath[++index]); } else { index = 0; pictureBox1.Load(arrPath[index]); } }
private void button3_Click(object sender, EventArgs e)//开始播放幻灯片 { if (pictureBox1.Image != null) { timer1.Enabled = true; } }
private void button4_Click(object sender, EventArgs e)//停止播放幻灯片 {
private void buttonMiddletoSide_Click(object sender, EventArgs e) {
if (pictureBox1.Image != null) {
//中间向两边拉伸 g = this.pictureBox1.CreateGraphics(); //初始为灰色 g.Clear(Color.Gray);
g.DrawImage(this.pictureBox1.Image, 0, 0, width, y); } g.Dispose(); } }
private void buttonReversal_Click(object sender, EventArgs e) {
if (pictureBox1.Image != null) {
ListViewItem item = listView1.SelectedItems[0]; index = item.ImageIndex; pictureBox1.Load(arrPath[index]);
}
2.3图片变换
private void buttonLeftToRight_Click(object sender, EventArgs e) { if (pictureBox1.Image != null) {
}
} g.Dispose(); } }
private void buttonExpand_Click(object sender, EventArgs e) {
if (pictureBox1.Image != null) {
//中间向四周扩散 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = 0; x <= width / 2; x++) {
private void buttonUptoDown_Click(object sender, EventArgs e) {
if (pictureBox1.Image != null) {
//上到下拉伸 g = this.pictureBox1.CreateGraphics(); //初始为灰色 g.Clear(Color.Gray); for (int y = 0; y <= height; y++) {
Leabharlann Baidu
{ OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "*.jpg;*.bmp|*.jpg;*.bmp;"; if (openFile.ShowDialog() == DialogResult.OK) { Bitmap srcBitmap = new Bitmap(openFile.FileName); myBitmap = new Bitmap(srcBitmap, this.pictureBox1.Width,
private void button2_Click(object sender, EventArgs e)//查看下一张 {
if (pictureBox1.Image != null) {
if (index < arrPath.Length - 1) {
pictureBox1.Load(arrPath[++index]); } else { index = 0; pictureBox1.Load(arrPath[index]); } }
2、实现过程 1)图片浏览器界面:界面简洁,功能明了。(如图)
图片浏览界面展示1(指定文件打开方式):
图片浏览界面展示2(目录树中打开选择图片文件夹):
listView中可选择显示方式
2.1指定文件打开,展示图片
private void ToolStripMenuItem_Click(object sender, EventArgs e)
if (pictureBox1.Image != null) {
if (index > 0) {
pictureBox1.Load(arrPath[--index]); } else { index = arrPath.Length; pictureBox1.Load(arrPath[--index]); } } }
private void button7_Click(object sender, EventArgs e)//左旋 {
if (pictureBox1.Image != null) {
pictureBox1.Image.RotateFlip(RotateFlipType.Rotate270FlipNone); pictureBox1.Refresh(); } }
//反转 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = -width / 2; x <= width / 2; x++) {
Rectangle DestRect = new Rectangle(0, height / 2 - x, width, 2 * x); Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height); g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel); } g.Dispose(); } }
Rectangle DestRect = new Rectangle(width / 2 - x, height / 2 - x, 2 * x, 2 * x);
Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height);
for (int y = 0; y <= width / 2; y++) {
Rectangle DestRect = new Rectangle(width / 2 - y, 0, 2 * y, height); Rectangle SrcRect = new Rectangle(0, 0, this.pictureBox1.Image.Width, this.pictureBox1.Image.Height); g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel);
if (pictureBox1.Image != null) {
timer1.Enabled = false; } }
2.4浏览上一张和下一张(此功能不适用与指定文件打开方式)
private void button1_Click(object sender, EventArgs e)//查看上一张 {
g.DrawImage(this.pictureBox1.Image, DestRect, SrcRect, GraphicsUnit.Pixel);
} g.Dispose(); } }
private void button5_Click(object sender, EventArgs e)//右旋 { if (pictureBox1.Image != null) { pictureBox1.Image.RotateFlip(RotateFlipType.Rotate90FlipNone); pictureBox1.Refresh(); } }
this.pictureBox1.Height); this.pictureBox1.Image = myBitmap; //this.pictureBox1.Image = Image.FromFile(openFile.FileName);
}
}
2.2双击listView选定项,展示选定图片
private void listView1_MouseDoubleClick(object sender, MouseEventArgs e) {
//左到右拉伸 g = this.pictureBox1.CreateGraphics(); g.Clear(this.BackColor); for (int x = 0; x <= width; x++) {
g.DrawImage(this.pictureBox1.Image, 0, 0, x, height); } g.Dispose(); } }
相关文档
最新文档