VB6浮雕效果原始碼

來源:互聯網
上載者:User

 
Private Sub Command1_Click()
    Dim r2, g2, b2 As Integer
    Dim r1, g1, b1 As Integer
    Dim c1 As Long
    Dim c2 As Long
    Dim x0 As Integer
    Dim y0 As Integer
    Screen.MousePointer = 11     'mouse呈沙漏形狀
    For x0 = 1 To Picture1.Width - 2
    For y0 = 1 To Picture2.Height - 2
        c1 = Picture1.Point(x0, y0)
        r1 = (c1 And &HFF)
        g1 = (c1 And 62580) / 256
        b1 = (c1 And &HFF0000) / 65536
        '獲得Picture1中指定點(x0,y0)的R、G、B分量值
       
        c2 = Picture1.Point(x0 + 1, y0 + 1)
        r2 = (c2 And &HFF)
        g2 = (c2 And 62580) / 256
        b2 = (c2 And &HFF0000) / 65536
        '獲得Picture1中與(x0,y0)點相鄰的點的R、G、B分量值
       
        r1 = Abs(r1 - r2 + 128)
        g1 = Abs(g1 - g2 + 128)
        b1 = Abs(b1 - b2 + 128)
        If r1 > 255 Then r1 = 255
        If r1 < 0 Then r1 = 0
        If b1 > 255 Then b1 = 255
        If b1 < 0 Then b1 = 0
        If g1 > 255 Then g1 = 255
        If g1 < 0 Then g1 = 0
        '計算浮雕處理後的R、G、B分量值
        Picture2.PSet (x0, y0), RGB(r1, g1, b1)
        '畫出浮雕處理後的(x0,y0)
        DoEvents
    Next
    Next
    Screen.MousePointer = 0   '恢複mouse正常情況

End Sub

Private Sub Form_Load()
    Picture1.Picture = LoadPicture(App.Path + "/鳥.bmp")
End Sub

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.