首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

这个C#程序哪出有关问题了

2012-01-19 
这个C#程序哪出问题了?using Systemusing System.Collections.Genericusing System.ComponentModelusin

这个C#程序哪出问题了?
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;
  }
  }
}

[解决办法]
没有问题啊,只是处理有点慢.你是想进行图片的特效处理吧?
[解决办法]
Bitmap im1 = new Bitmap(im); 报错???
肯看im为什么为空
[解决办法]
picturebox中有图像吗?
[解决办法]

探讨
picturebox中有图像吗?

[解决办法]
检查一下picturebox啊
探讨
引用:
picturebox中有图像吗?

[解决办法]
我原封不动的粘贴了你的代码,没有任何问题,还是看看pictureBox1中是否有图像

热点排行