C#编程实现图像处理 20
毕业设计做的是C#实现图像处理,平台是Microsoftvisualstudio2008,我已实现了大部分功能,现在缺少的是以下几个功能:1、拖动鼠标选中一块矩形区域2、...
毕业设计做的是C#实现图像处理,平台是Microsoft visual studio 2008,我已实现了大部分功能,现在缺少的是以下几个功能:
1、拖动鼠标选中一块矩形区域
2、将鼠标选中的区域的像素值改成与背景相同的。
3、修改完毕的部分图像和整体图像合并保存。
哪位高手能给点建议?代码算法都行。多谢。 展开
1、拖动鼠标选中一块矩形区域
2、将鼠标选中的区域的像素值改成与背景相同的。
3、修改完毕的部分图像和整体图像合并保存。
哪位高手能给点建议?代码算法都行。多谢。 展开
2个回答
展开全部
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;
using System.Drawing.Imaging;
namespace WindowsFormsApplication17
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int RD;
public Color C;
public int D_M_X;
public int D_M_Y;
public int U_M_X;
public int U_M_Y;
private void button1_Click(object sender, EventArgs e)
{
Bitmap T_C = (Bitmap)pictureBox1.Image;
for (int a = D_M_X; a <= U_M_X - D_M_Y; a++)
{
for (int b = D_M_Y; b <= U_M_Y - D_M_Y; a++)
{
T_C.SetPixel(a,b,C);
}
}
pictureBox1.Image = T_C;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
RD = 1;
pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
RD = 2;
pictureBox1.MouseDown += new MouseEventHandler(pictureBox11_MouseDown);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Bitmap bit = (Bitmap)pictureBox1.Image;
Color C = bit.GetPixel(e.X, e.Y);
Bitmap T_C = new Bitmap(pictureBox2.Width, pictureBox2.Height);
for (int a = 0; a <= T_C.Width - 1; a++)
{
for (int b = 0; b <= T_C.Height - 1; b++)
{
T_C.SetPixel(a, b, Color.FromArgb(C.R, C.G, C.B));
}
}
pictureBox2.Image = T_C;
button1.Text = C.R.ToString();
}
private void pictureBox11_MouseDown(object sender, MouseEventArgs e)
{
D_M_X = e.X;
D_M_Y = e.Y;
pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
pictureBox1.MouseUp+=new MouseEventHandler(pictureBox1_MouseUP);
}
private void pictureBox1_MouseUP(object sender,MouseEventArgs e)
{
D_M_X = e.X;
D_M_Y = e.Y;
}
}
}
只是一个思路 你看下 程序不好 只是一个思路。。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Imaging;
namespace WindowsFormsApplication17
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public int RD;
public Color C;
public int D_M_X;
public int D_M_Y;
public int U_M_X;
public int U_M_Y;
private void button1_Click(object sender, EventArgs e)
{
Bitmap T_C = (Bitmap)pictureBox1.Image;
for (int a = D_M_X; a <= U_M_X - D_M_Y; a++)
{
for (int b = D_M_Y; b <= U_M_Y - D_M_Y; a++)
{
T_C.SetPixel(a,b,C);
}
}
pictureBox1.Image = T_C;
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
RD = 1;
pictureBox1.MouseDown += new MouseEventHandler(pictureBox1_MouseDown);
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
RD = 2;
pictureBox1.MouseDown += new MouseEventHandler(pictureBox11_MouseDown);
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Bitmap bit = (Bitmap)pictureBox1.Image;
Color C = bit.GetPixel(e.X, e.Y);
Bitmap T_C = new Bitmap(pictureBox2.Width, pictureBox2.Height);
for (int a = 0; a <= T_C.Width - 1; a++)
{
for (int b = 0; b <= T_C.Height - 1; b++)
{
T_C.SetPixel(a, b, Color.FromArgb(C.R, C.G, C.B));
}
}
pictureBox2.Image = T_C;
button1.Text = C.R.ToString();
}
private void pictureBox11_MouseDown(object sender, MouseEventArgs e)
{
D_M_X = e.X;
D_M_Y = e.Y;
pictureBox1.MouseMove += new MouseEventHandler(pictureBox1_MouseMove);
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
pictureBox1.MouseUp+=new MouseEventHandler(pictureBox1_MouseUP);
}
private void pictureBox1_MouseUP(object sender,MouseEventArgs e)
{
D_M_X = e.X;
D_M_Y = e.Y;
}
}
}
只是一个思路 你看下 程序不好 只是一个思路。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |