我的WinForm里有一个pictureBox1控件,有一张图片c:\test.jpg
我想载入图片到pictureBox1控件后,能在图片上有一个可以在pictureBox1控件里移动的矩形框,
在矩形框里显示的正常的图像,而未在矩形框内显示的就变暗一点。就像photoshop里的剪裁选择的效果,只不过我不要求矩形框能缩变,固定大小就行了。哪位高手能解决呢,谢谢。
我想载入图片到pictureBox1控件后,能在图片上有一个可以在pictureBox1控件里移动的矩形框,
在矩形框里显示的正常的图像,而未在矩形框内显示的就变暗一点。就像photoshop里的剪裁选择的效果,只不过我不要求矩形框能缩变,固定大小就行了。哪位高手能解决呢,谢谢。
解决方案 »
- C#在远程计算机上创建新用户账号,修改用户密码,删除一个用户账号的功能?
- InstallShield2009打包生成MSI文件的问题
- 请大家帮忙推荐一个在进行开发的.Net开源项目,方便参与和学习!
- 请问大家做测试的时候都用什么工具?
- 如何解决客户端webservice传递参数长度限制?
- TreeList怎么根据节点的名称,设置选中的节点
- 救命呀!请问大侠们 如何把CheckBox,下拉框等改成平面的??
- exchange 为指定用户列表创建appointment
- .NET的版本问题
- ASP.NET能不能调用服务器上的API函数!
- DataGrid_Update更新日期列时,日期列都变成了旁边列的姓名,而数据库中的日期已更新了。怎么回事啊,帮帮忙!!!!
- 一个DataGrid的简单问题
2,可以直接做一个同样大小的点网图
给你个方案吧,你可以创建一张同样大小的灰度图片,然后进行ALPHA混合,就可以得到较暗的图,接下来再把要变亮的部份贴上去,
2,可以直接做一个同样大小的点网图
就这样,移动矩形框,就是贴不同的块上去。
using System;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
namespace ViewPicture
{
public class frmViewImg : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null; private System.Windows.Forms.PictureBox pictureBox1;
private bool mouseDown = false;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.PictureBox pictureBox2;
private Point point ; public frmViewImg()
{
InitializeComponent();
} protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmViewImg));
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.panel2 = new System.Windows.Forms.Panel();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.Color.Transparent;
this.pictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
this.pictureBox1.Location = new System.Drawing.Point(232, 152);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(152, 144);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseUp);
this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
//
// panel2
//
this.panel2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panel2.BackgroundImage")));
this.panel2.Controls.Add(this.pictureBox1);
this.panel2.Controls.Add(this.pictureBox2);
this.panel2.Location = new System.Drawing.Point(24, 64);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(560, 472);
this.panel2.TabIndex = 3;
//
// pictureBox2
//
this.pictureBox2.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("pictureBox2.BackgroundImage")));
this.pictureBox2.Location = new System.Drawing.Point(0, 0);
this.pictureBox2.Name = "pictureBox2";
this.pictureBox2.Size = new System.Drawing.Size(560, 472);
this.pictureBox2.TabIndex = 0;
this.pictureBox2.TabStop = false;
//
// frmViewImg
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 12);
this.ClientSize = new System.Drawing.Size(632, 581);
this.Controls.Add(this.panel2);
this.Name = "frmViewImg";
this.Text = "?示?片";
this.panel2.ResumeLayout(false);
this.ResumeLayout(false); }
[STAThread]
static void Main()
{
Application.Run(new frmViewImg());
} private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
mouseDown = true;
point = new Point(e.X, e.Y);
}
} private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
mouseDown = false;
} private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(mouseDown)
{
pictureBox1.Location = new Point(pictureBox1.Left + e.X - point.X, pictureBox1.Top + e.Y - point.Y); this.pictureBox2.Refresh();
this.pictureBox1.Refresh();
}
}
}
}希望有点用处!