📄 用c#实现的图象处理(源代码)------正在更新中! - lijigang1982的专栏 - csdnblog.htm
字号:
e)<BR> {<BR> Graphics g = this.CreateGraphics ( )
;<BR> g.Clear(this.BackColor);<BR> Color c1
=new
Color();<BR>
Color c2 =new Color();<BR> Color c3 =new
Color();<BR> Color c4 =new Color();<BR> Bitmap
box1= new Bitmap(pictureBox1.Image);<BR> for (int
i=0;i<this.pictureBox1.Image.Width-2;i++)<BR> {<BR> for
(int
j=0;j<this.pictureBox1.Image.Height-2;j++)<BR> {<BR> c1=box1.GetPixel(i,j);<BR> c2=box1.GetPixel(i+1,j+1);<BR>
c3=box1.GetPixel(i+1,j);<BR> c4=box1.GetPixel(i,j+1);<BR> int
rr=Math.Abs(c1.R-c2.R)+Math.Abs(c3.R-c4.R)+128;<BR> if(rr<0)
rr=0;<BR> if(rr>255)
rr=255;<BR> int
gg=Math.Abs(c1.G-c2.G)+Math.Abs(c3.G-c4.G)+128;<BR> if(gg<0)
gg=0;<BR> if(gg>255)
gg=255;<BR> int
bb=Math.Abs(c1.B-c2.B)+Math.Abs(c3.B-c4.B)+128;<BR> if(bb<0)
bb=0;<BR> if(bb>255)
bb=255;<BR> Color c =
Color.FromArgb(rr,gg,bb);<BR> box1.SetPixel(i,j,c);<BR> }<BR> pictureBox1.Refresh();<BR> pictureBox1.Image=box1;<BR> }<BR> g.Dispose();<BR> }</P>
<P> private void menuItem9_Click(object sender, System.EventArgs
e)<BR> {<BR>// this.pictureBox2.Visible=false;<BR>// this.label2.Visible=false;<BR>
Bitmap box1= new Bitmap(pictureBox1.Image);<BR> Graphics
g = this.CreateGraphics ( )
;<BR> g.Clear(this.BackColor);<BR> Matrix X =
new Matrix ( )
;<BR> //创建Matrix实例<BR> X.Translate ( 100,100 )
;
<BR> //调用Matrix实例的Translate方法,并以此方法作用于Matrix实例<BR> g.Transform
= X ;<BR> //设定图片效果<BR> g.DrawImage ( box1 ,
<BR> new Rectangle ( this.pictureBox1.Width , 0 ,
box1.Width , box1.Height ) , <BR> 0 ,0 ,
box1.Width , <BR> box1.Height ,
<BR> GraphicsUnit.Pixel ) ;
<BR> X.Dispose ( ) ;<BR> g.Dispose ( )
;<BR> }</P>
<P> private void menuItem24_Click(object sender, System.EventArgs
e)<BR> {
<BR> //先把要处理的东西绘制到图象控件上,再在完成了所有的绘图操作后,把图象控件整个<BR> //转给picturebox1控件,就是这个思路!<BR> Graphics
g =
this.CreateGraphics();<BR> g.Clear(this.BackColor);<BR>
Bitmap bitmap=new Bitmap(pictureBox1.Image);<BR> Bitmap
bitmap1=new
Bitmap(pictureBox1.Width,pictureBox1.Height);<BR> Graphics g1=
Graphics.FromImage(bitmap1);<BR> float[][] ptsArray ={
<BR> new float[] {1, 0, 0,
0, 0},<BR> new float[] {0,
1, 0, 0, 0},<BR> new
float[] {0, 0, 1, 0,
0},<BR> new float[] {0, 0,
0, 0.5f, 0},
//注意:此处为0.1f,图像为强透明<BR> new
float[] {0, 0, 0, 0, 1}}; <BR>// MessageBox.Show("当前透明度设置为:"+
ptsArray[3][3]*100 + "%");<BR>
Form3 newform3 = new
Form3();<BR> newform3.trackBar1.SetRange(10,100);<BR> newform3.trackBar1.SmallChange=10;<BR> newform3.label1.Text="10";<BR> newform3.label3.Text="100";<BR> newform3.trackBar1.Value=50;<BR> newform3.label2.Text="";<BR> newform3.Text="设置透明度";<BR> newform3.ShowDialog(this);//注意一定不能把newform3的属性设置放在此句后,否则……
<BR> ptsArray[3][3]=(float)newform3.trackBar1.Value/100;<BR> ColorMatrix
clrMatrix = new ColorMatrix(ptsArray);<BR> ImageAttributes
imgAttributes = new
ImageAttributes();<BR> //设置图像的颜色属性<BR> imgAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default,
<BR> ColorAdjustType.Bitmap);<BR> //画图像<BR> g1.DrawImage(bitmap,
new Rectangle(0, 0, bitmap.Width, bitmap.Height), <BR> 0,
0, bitmap.Width, bitmap.Height,<BR> GraphicsUnit.Pixel,
imgAttributes);<BR> this.pictureBox1.Image=bitmap1;<BR> g.Dispose();<BR> newform3.Dispose();<BR> }</P>
<P> private void menuItem10_Click(object sender, System.EventArgs
e)<BR> {<BR> <BR> }</P>
<P> private void menuItem13_Click(object sender, System.EventArgs
e)<BR> {<BR> Graphics g = this.CreateGraphics ( )
;<BR> g.Clear(this.BackColor);<BR> Bitmap
BmpTemp= new Bitmap(pictureBox1.Image);<BR> Matrix X = new
Matrix ( ) ;<BR> //创建Matrix实例<BR> X.Scale (
(float)0.5 ,1 , MatrixOrder.Append )
;<BR> //调用Matrix实例的Scale方法,并以此方法作用于Matrix实例<BR> g.Transform
= X ; <BR> g.DrawImage ( BmpTemp ,
<BR> new Rectangle ( 10 ,250 , 200 , 200 ) ,
<BR> 0 , 0 , BmpTemp.Width ,
<BR> BmpTemp.Height ,
<BR> GraphicsUnit.Pixel ) ;
<BR> X.Dispose ( ) ;<BR> g.Dispose ( )
;<BR> //清除资源 <BR> <BR> }</P>
<P> private void pictureBox1_SizeChanged(object sender,
System.EventArgs
e)<BR> {<BR>// pictureBox2.Location=new
Point(this.pictureBox1.Width,this.pictureBox1.ClientRectangle.Y);<BR> }</P>
<P> private void menuItem25_Click(object sender, System.EventArgs
e)<BR> {<BR> Graphics g=
this.CreateGraphics();<BR>
g.Clear(this.BackColor);<BR> this.pictureBox1.Image=m_copybitmap;<BR> g.Dispose();<BR> }<BR> <BR> }<BR>}<BR></P>
<P></P><BR><BR>
<P id=TBPingURL>Trackback:
http://tb.blog.csdn.net/TrackBack.aspx?PostId=513854</P><BR></DIV>
<DIV class=postFoot>
<SCRIPT src=""></SCRIPT>
[<A title=功能强大的网络收藏夹,一秒钟操作就可以轻松实现保存带来的价值、分享带来的快乐
href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(saveit=window.open('http://wz.csdn.net/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=590,height=300,left=75,top=20,status=no,resizable=yes'));saveit.focus();">收藏到我的网摘</A>]
lijigang1982发表于 2005年10月22日 22:33:00 </DIV></DIV><LINK
href="http://blog.csdn.net/lijigang1982/Services/Pingback.aspx" rel=pingback><!--<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"xmlns:dc="http://purl.org/dc/elements/1.1/"xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"><rdf:Descriptionrdf:about="http://blog.csdn.net/lijigang1982/archive/2005/10/22/513854.aspx"dc:identifier="http://blog.csdn.net/lijigang1982/archive/2005/10/22/513854.aspx"dc:title="用C#实现的图象处理(源代码)------正在更新中!"trackback:ping="http://tb.blog.csdn.net/TrackBack.aspx?PostId=513854" /></rdf:RDF>-->
<SCRIPT>function hide(){showComment();}</SCRIPT>
<BR>
<DIV class=post>
<DIV class=postTitle>相关文章:</DIV>
<UL class=postText>
<LI><A href="http://blog.csdn.net/net_lover/archive/2002/05/16/6902.aspx"
target=_blank>C#写的记事本</A> 2002-05-16 <A href="http://blog.csdn.net/net_lover/"
target=_blank>net_lover</A>
<LI><A href="http://blog.csdn.net/yangming0423/archive/2006/04/21/672405.aspx"
target=_blank>直接拉入图片文件到程序窗口中打开的C#程序</A> 2006-04-21 <A
href="http://blog.csdn.net/yangming0423/" target=_blank>yangming0423</A>
<LI><A href="http://blog.csdn.net/Yellow198267/archive/2006/05/17/743329.aspx"
target=_blank>实现winform 中的分割窗体效果</A> 2006-05-17 <A
href="http://blog.csdn.net/Yellow198267/" target=_blank>Yellow198267</A>
<LI><A href="http://blog.csdn.net/yufengly/archive/2004/04/20/18919.aspx"
target=_blank>利用C#在SQL Server2000存取图像 For Window</A> 2004-04-20 <A
href="http://blog.csdn.net/yufengly/" target=_blank>yufengly</A>
<LI><A href="http://blog.csdn.net/j7a7c7k7/archive/2005/01/19/259824.aspx"
target=_blank>利用TextEditorControl控件现代码语法高亮显示</A> 2005-01-19 <A
href="http://blog.csdn.net/j7a7c7k7/"
target=_blank>j7a7c7k7</A></LI></UL></DIV><BR>
<DIV id=tagad>
<SCRIPT language=javascript>
ad_width=468;
ad_height=60;
adcss=2;
unionuser=13;
</SCRIPT>
<SCRIPT language=javascript
src="用C#实现的图象处理(源代码)------正在更新中! - lijigang1982的专栏 - CSDNBlog.files/showads.js"
type=text/javascript>
</SCRIPT>
</DIV>
<SCRIPT type=text/javascript>document.write("<img src=http://counter.csdn.net/pv.aspx?id=24 border=0 width=0 height=0>");</SCRIPT>
<A name=1337540> </A>
<DIV class=post>
<DIV class=postTitle><A href="http://321/" target=_blank
rel=nofollow>123</A> 发表于2006-10-17 01:50:00 IP: 85.101.0.*</DIV>
<DIV class=postText>321321321</DIV></DIV><BR>
<DIV class=CommentForm id=commentform>
<H3>发表评论</H3>
<TABLE class=CommentForm>
<TBODY>
<TR>
<TD width=69 height=0></TD>
<TD></TD></TR>
<TR>
<TD width=70>大名:</TD>
<TD align=left><INPUT id=PostComment.ascx_tbName style="WIDTH: 300px"
size=40 name=PostComment.ascx$tbName> <SPAN
id=PostComment.ascx_RequiredFieldValidator2
style="DISPLAY: none; COLOR: red"><BR>请输入尊姓大名</SPAN> </TD></TR>
<TR>
<TD width=70>网址:</TD>
<TD align=left><INPUT id=PostComment.ascx_tbUrl style="WIDTH: 300px"
size=40 name=PostComment.ascx$tbUrl> </TD></TR>
<TR>
<TD colSpan=3>评论 <SPAN id=PostComment.ascx_RequiredFieldValidator3
style="DISPLAY: none; COLOR: red"><BR>请输入评论</SPAN> <BR><TEXTAREA id=PostComment.ascx_tbComment style="WIDTH: 381px; HEIGHT: 193px" name=PostComment.ascx$tbComment rows=10 cols=50></TEXTAREA>
</TD></TR>
<TR style="DISPLAY: none">
<TD height=24>验证码</TD>
<TD><INPUT id=PostComment.ascx_ValidationKey style="WIDTH: 150px"
name=PostComment.ascx$ValidationKey> <INPUT id=VCImageSrc type=hidden
value=/VerifyCode.aspx?url=http%3a%2f%2fblog.csdn.net%2flijigang1982%2farchive%2f2005%2f10%2f22%2f513854.aspx&datetime=11%2f2%2f2006+10%3a04%3a41+PM&ip=218.2.186.126>
<SPAN id=VCImageSpan></SPAN>
<SCRIPT
src="用C#实现的图象处理(源代码)------正在更新中! - lijigang1982的专栏 - CSDNBlog.files/deferShowVerifyImage.js"
type=text/javascript></SCRIPT>
</TD></TR>
<TR>
<TD colSpan=3><INPUT class=Button id=PostComment.ascx_btnSubmit onclick='javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("PostComment.ascx$btnSubmit", "", true, "", "", false, false))' type=submit value=提交 name=PostComment.ascx$btnSubmit>
<INPUT id=PostComment.ascx_chkRemember type=checkbox
name=PostComment.ascx$chkRemember><LABEL
for=PostComment.ascx_chkRemember>记住我?</LABEL></TD></TR>
<TR>
<TD colSpan=3><SPAN id=PostComment.ascx_Message
style="COLOR: red"></SPAN></TD></TR></TBODY></TABLE></DIV></DIV>
<P id=footer>Powered by: <BR><A id=Footer1_Hyperlink2
href="http://scottwater.com/blog" name=Hyperlink1><IMG
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px"
src="用C#实现的图象处理(源代码)------正在更新中! - lijigang1982的专栏 - CSDNBlog.files/100x30_Logo.gif"></A>
<A id=Footer1_Hyperlink3 href="http://asp.net/" name=Hyperlink1><IMG
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -