using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 图片处理
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Color c1, c2;
int r, g, b;
Bitmap im = new Bitmap(pictureBox1.Image);
Bitmap im1 = new Bitmap(im);
for (int i = 0; i < im.Width - 1; i++)
for (int j = 0; j < im.Height - 1; j++)
{
c1 = im.GetPixel(i, j);
c2 = im.GetPixel(i + 1, j + 1);
r = Math.Abs(c1.R - c2.R) + 128;
g = Math.Abs(c1.G - c2.G) + 128;
b = Math.Abs(c1.B - c2.B) + 128;
if (r < 0) r = 0;
if (r > 255) r = 255;
if (g < 0) g = 0;
if (g > 255) g = 255;
if (b < 0) b = 0;
if (b > 255) b = 255;
Color cc = Color.FromArgb(r, g, b);
im1.SetPixel(i, j, cc);
}
pictureBox2.Image = im1;
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace 图片处理
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button1_Click(object sender, EventArgs e)
{
Color c1, c2;
int r, g, b;
Bitmap im = new Bitmap(pictureBox1.Image);
Bitmap im1 = new Bitmap(im);
for (int i = 0; i < im.Width - 1; i++)
for (int j = 0; j < im.Height - 1; j++)
{
c1 = im.GetPixel(i, j);
c2 = im.GetPixel(i + 1, j + 1);
r = Math.Abs(c1.R - c2.R) + 128;
g = Math.Abs(c1.G - c2.G) + 128;
b = Math.Abs(c1.B - c2.B) + 128;
if (r < 0) r = 0;
if (r > 255) r = 255;
if (g < 0) g = 0;
if (g > 255) g = 255;
if (b < 0) b = 0;
if (b > 255) b = 255;
Color cc = Color.FromArgb(r, g, b);
im1.SetPixel(i, j, cc);
}
pictureBox2.Image = im1;
}
}
}
解决方案 »
- WPF的控件,除了Tag和ToolTip能够放入字符串外,还有什么属性能放入字符串?
- 请高手指导下关于用==判断string相等的问题
- c# 如何设置LISTVIEW为网格形式!
- 做随机数生成,如何让那些生成的数一直在跳,就像摇奖那样?
- 关于checkbox的勾选问题
- C# 如何创建一个类似网盘那样的磁盘
- 系统安装程序制作问题
- ComboBox TextUpdate事件 首次输入词组(广州)会触发2次,最后text= "州"
- 那里有C#的技术文档?最好是电子板的。
- 能不能在HyperlinkColumn的URL格式化字符串里传送两个绑定的字段
- 完善我的这个代码
- [高手请进]请问如果在C#中保存住C++的函数指针.
排错提示:
使用“new”关键字创建对象实例。
在调用方法前通过检查确定对象是否为空。
获取此异常的常规帮助。
搜索更多联机帮助操作:
查看详细信息
将异常详细信息复制到剪贴板
肯看im为什么为空
好象是 Bitmap im = new Bitmap(pictureBox1.Image); 抱错!