'伽玛 Private Sub Button2_Click(sender As Object,e As EventArgs) Handles Button2.Click Dim destImg As New Bitmap(sourceImg.Width,sourceImg.Height) Dim imageAttributes As New ImageAttributes() imageAttributes.SetGamma(0.5F) Dim g As Graphics = Graphics.FromImage(destImg) g.DrawImage(sourceImg,New Rectangle(0,sourceImg.Width,sourceImg.Height),sourceImg.Height,GraphicsUnit.Pixel,imageAttributes) picDest.Image = destImg End Sub@H_403_0@ 运行效果:
Private Sub Button3_Click(sender As Object,e As EventArgs) Handles Button3.Click Dim destImg As New Bitmap(sourceImg.Width,sourceImg.Height) Dim imageAttributes As New ImageAttributes() imageAttributes.SetThreshold(0.7F) Dim g As Graphics = Graphics.FromImage(destImg) g.DrawImage(sourceImg,imageAttributes) picDest.Image = destImg End Sub@H_403_0@ 运行效果: @H_403_0@
'颜色替换 Private Sub Button1_Click(sender As Object,e As EventArgs) Handles Button1.Click Dim destImg As New Bitmap(sourceImg.Width,sourceImg.Height) Dim mycolormap(0) As ColorMap mycolormap(0) = New ColorMap() mycolormap(0).OldColor = Color.Black mycolormap(0).NewColor = Color.Red Dim imageAttributes As New ImageAttributes() imageAttributes.SetRemapTable(mycolormap) Dim g As Graphics = Graphics.FromImage(destImg) g.DrawImage(sourceImg,imageAttributes) picDest.Image = destImg End Sub@H_403_0@ 运行效果: @H_403_0@
由于.net平台下C#和vb.NET很相似,本文也可以为C#爱好者提供参考。
学习更多vb.net知识,请参看 vb.net 教程 目录
原文链接:https://www.f2er.com/vb/256638.html