| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 703 人关注过本帖
标题:引用GDI32中FloodFill问题
只看楼主 加入收藏
tty1960
Rank: 1
等 级:新手上路
帖 子:83
专家分:0
注 册:2006-10-16
收藏
 问题点数:0 回复次数:0 
引用GDI32中FloodFill问题

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace getpixl
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
Bitmap bitmap=null;
Graphics ig =null;

public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.SuspendLayout();
//
// pictureBox1
//
this.pictureBox1.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.pictureBox1.Location = new System.Drawing.Point(16, 24);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(760, 544);
this.pictureBox1.TabIndex = 0;
this.pictureBox1.TabStop = false;
this.pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseDown);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(760, 574);
this.Controls.Add(this.pictureBox1);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
[ System.Runtime.InteropServices.DllImportAttribute ( "gdi32.dll" , EntryPoint="FloodFill")]
static extern int FloodFill( IntPtr hDC , int X , int Y ,int newColor);
private void Form1_Load(object sender, System.EventArgs e)
{
/*bitmap = new Bitmap (pictureBox1 .Width ,pictureBox1 .Height );

Graphics g=pictureBox1.CreateGraphics();
Pen curpen=new Pen(Color.Black);
g.DrawRectangle(curpen,10,10,100,100);
ig.DrawRectangle(curpen,10,10,100,100);
pictureBox1.Image=bitmap;*/

}

private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{ bitmap = new Bitmap (pictureBox1 .Width ,pictureBox1 .Height );
ig = Graphics.FromImage (bitmap);
IntPtr dc=ig.GetHdc();
Color newColor=Color.Black;
int oldColor=newColor.ToArgb();
FloodFill( dc, e.X , e.Y , oldColor);
pictureBox1.Image=bitmap;
ig.ReleaseHdc(dc);
}
}
}

搜索更多相关主题的帖子: FloodFill 
2006-12-12 22:36
快速回复:引用GDI32中FloodFill问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015056 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved