资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace final public partial class Form1 : Form public Form1() InitializeComponent(); Bitmap recBitmap; private void openToolStripMenuItem_Click(object sender, EventArgs e) OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.ShowDialog(); String fileName = openFileDlg.FileName; recBitmap = new Bitmap(fileName); recPicBox.Image = recBitmap; private void rToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); int r = c.R; Color cc = Color.FromArgb(r, 0, 0); decBitmap.SetPixel(i, j, cc); decPicBox.Image = decBitmap; private void gToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); int g = c.G; Color cc = Color.FromArgb(0, g, 0); decBitmap.SetPixel(i, j, cc); decPicBox.Image = decBitmap; private void bToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); int b = c.B; Color cc = Color.FromArgb(0, 0, b); decBitmap.SetPixel(i, j, cc); decPicBox.Image = decBitmap; private void grayToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); int r = c.R; int g = c.G; int b = c.B; int gray = (r + g + b) / 3; Color cc = Color.FromArgb(gray, gray, gray); decBitmap.SetPixel(i, j, cc); decPicBox.Image = decBitmap; private void vToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); decBitmap.SetPixel(width - i - 1, j, c); decPicBox.Image = decBitmap; private void gToolStripMenuItem1_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); decBitmap.SetPixel(i, height - j - 1, c); decPicBox.Image = decBitmap; private void vtToolStripMenuItem_Click(object sender, EventArgs e) int width = recBitmap.Width; int height = recBitmap.Height; Bitmap decBitmap = new Bitmap(width, height); for (int i = 0; i width; i+) for (int j = 0; j height; j+) Color c = recBitmap.GetPixel(i, j); int vtran = i - width / 3; if (vtran 0) vtran = 0; decBitmap.SetPixel(vtran, j, c);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号