晨风资讯网
新闻资讯网络冲浪网页设计网络编程图形图像数据库网络媒体服务器网络安全网站运营软件教程黑客认证Wap技术
教程搜索
教程搜索:
  首页 > 程序开发 > VB/VB.NET > 正文  

VB.NET2005计算图像的颜色变化(浮雕)
日期:2008-6-27 13:54:25 来源: 作者: 浏览:

VB.NET2005计算图像的颜色变化(浮雕)
Public Function TrunBlackWhite(ByVal img As Image) As Image
        '转黑白
        Dim g As Graphics = Graphics.FromImage(img)
        Dim ia As New ImageAttributes()
        Dim colorMatrix As Single()() = {New Single() {0.3F, 0.3F, 0.3F, 0.0, 0.0}, _
                                        New Single() {0.59F, 0.59F, 0.59F, 0.0, 0.0}, _
                                        New Single() {0.11F, 0.11F, 0.11F, 0.0, 0.0}, _
                                        New Single() {0.0, 0.0, 0.0, 1.0, 0.0}, _
                                        New Single() {0.0, 0.0, 0.0, 0.0, 1.0}}
        Dim cm As New ColorMatrix(colorMatrix)
        ia.SetColorMatrix(cm, ColorMatrixFlag.Default, ColorAdjustType.Default)
        g.DrawImage(img, New Rectangle(0, 0, img.Width, img.Height), 0, 0, img.Width, img.Height, _
        GraphicsUnit.Pixel, ia)
        g.Dispose()
        Return img
    End Function

    Public Function GetImageLine(ByVal img As Image) As Image
        '浮雕
        Dim red, green, blue As Integer
        Dim DispX As Integer = 1, DispY As Integer = 1
        Dim bmp As New Bitmap(img)
        For y As Integer = 0 To bmp.Height - 2
            For x As Integer = 0 To bmp.Width - 2
                Dim pixel1, pixel2 As System.Drawing.Color
                pixel1 = bmp.GetPixel(x, y)
                pixel2 = bmp.GetPixel(x + DispX, y + DispY)
                red = Math.Min(Math.Abs(CInt(pixel1.R) - CInt(pixel2.R)), 255)
                green = Math.Min(Math.Abs(CInt(pixel1.G) - CInt(pixel2.G)), 255)
                blue = Math.Min(Math.Abs(CInt(pixel1.B) - CInt(pixel2.B)), 255)
                bmp.SetPixel(x, y, Color.FromArgb(red, green, blue))
            Next
            Application.DoEvents()
        Next
        Return bmp
    End Function


上一篇: VB.NET2005图像的锐化和钝化的计算 下一篇:

VB.NET2005从网页源码中分离文本

返回列表 打印此页 加入收藏 资讯论坛 关闭窗口 点击复制本页地址,发送给QQ/MSN好友
关于我们 - 联系我们 - 版权声明 - 帮助(?) - 广告服务 - 友情链接 - 服务项目 - 人才招聘
2003-2008 版权所有 © 晨风资讯网 未经授权禁止复制或建立镜像
CopyRight 2003-2008 www.Net118.com,All Rights Reserved.Design By ChenFeng Network Studio