English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

小弟在網路上看到一篇 Picture圖形20%的通透 教學但是執行時出現錯誤
請有心人士可以幫我解答哪裡錯了 ! 教學文章如下:
==================================================================
●很多圖形的影像處理,講明了只是演算法的問題,先前的步驟就是將圖形的R(紅)、G(綠)、B(藍)等值提出來並分離,分別將R、G、B等值做處理後再以合並重繪。
●在影像處理軟體裡,n%的透明貼圖如何辦到?說穿了透明貼圖並不是很高深的演算法,只是參考來源圖形的顏色改變一下目的圖形的R、G、B值的增減比例,如要以來源圖形做參考,在目的圖形上做50%的透明貼圖,計算法等於:RGB(來源的R值 * 0.5 + 目的的R值 * 0.5, 來源的G值 * 0.5 + 目的的G值 * 0.5, 來源的B值 * 0.5 + 目的的B值 * 0.5)或RGB((來源的R值 + 目的的R值)/2, (來源的G值 + 目的的G值)/2, (來源的B值 + 目的的B值)/2)
●底下以範例來示範透明度為20%的透明貼圖:
●如右圖的佈置,兩個PictureBox,分別為Picture1與Picture2,Picture2為小瓜瓜大頭照,Picture1放著是色X網站上抓來的香辣圖形,原本是為了要服務網友們,但圖太大了,只好請網友們自行想像了,然後還有一個Command1,這才是最重要的。


Private Sub Command1_Click()
Dim SorColor As Long, TarColor As Long, RepColor As Long
Dim LocX As Single, LocY As Single
Dim SorR As Integer, SorG As Integer, SorB As Integer
Dim TarR As Integer, TarG As Integer, TarB As Integer

Picture1.AutoRedraw = True
For LocX = 0 To Picture2.ScaleWidth
For LocY = 0 To Picture2.ScaleHeight

SorColor = Picture2.Point(LocX, LocY)
TarColor = Picture1.Point(LocX, LocY)

SorR = SorColor And &HFF&
SorG = (SorColor And &HFF00&) / &H100&
SorB = (SorColor And &HFF0000) / &H10000
TarR = TarColor And &HFF&
TarG = (TarColor And &HFF00&) / &H100&
TarB = (TarColor And &HFF0000) / &H10000

Picture1.PSet (LocX, LocY), RGB((TarR * 4 + SorR) / 5, (TarG * 4 + SorG) / 5, (TarB * 4 + SorB) / 5)

Next
Next

Picture1.AutoRedraw = False
End Sub
==================================================================
我依照上面的程式碼寫好了執行沒有反應
正常因該會將第二張圖繪在第一張上面但是沒有、程式碼故障 . . .

2006-12-02 06:51:22 · 2 個解答 · 發問者 leecach 2 in 電腦與網際網路 程式設計

2 個解答

Private Type nRGB        R As Integer        G As Integer        B As IntegerEnd TypePrivate Sub Form_Load()    Picture1.ScaleMode = 3    Picture2.ScaleMode = 3    Picture2.Width = Picture1.Width    Picture2.Height = Picture1.HeightEnd SubPrivate Sub Command1_Click()    Dim X&, Y&, P1 As nRGB, P2 As nRGB    On Error Resume Next        Picture1.AutoRedraw = True    For X = 0 To Picture2.ScaleWidth        For Y = 0 To Picture2.ScaleHeight            P1 = Long2RGB(Picture1.Point(X, Y))            P2 = Long2RGB(Picture2.Point(X, Y))            '這是小瓜瓜的計算方式            Picture1.PSet (X, Y), RGB((P1.R * 4 + P2.R) \ 5, (P1.G * 4 + P2.G) \ 5, (P1.B * 4 + P2.B) \ 5)            '這是你定義的方式(個人認為小瓜瓜的計算方式比較正確XD)            'Picture1.PSet (X, Y), RGB((P1.R + P2.R) *0.2, (P1.G + P2.G) *0.2, (P1.B + P2.B)*0.2)            DoEvents        Next    Next    Picture1.AutoRedraw = FalseEnd SubPrivate Function Long2RGB(ByVal L As Long) As nRGB    Long2RGB.R = L Mod 256: L = L \ 256    Long2RGB.G = L Mod 256: L = L \ 256    Long2RGB.B = L Mod 256End Function

2006-12-02 19:45:19 · answer #1 · answered by W.J.S. 7 · 0 0

到下面的網址看看吧

▶▶http://qoozoo09260.pixnet.net/blog

2014-10-01 18:05:42 · answer #2 · answered by Anonymous · 0 0

fedest.com, questions and answers