' Ïðîöåäóðà àíèìèðóåò ôîí
Private Sub Release()
Dim x As Long, y As Long, c As Long, d As Long, w As Long, h As Long
Dim r As Long, g As Long, b As Long, a As Long, dx As Long, dy As Long
Dim cx As Single, cy As Single, Buf() As Long, o As Single, s As Single
' Îïðåäåëÿåì øèðèíó è âûñîòó ðèñóíêà - 1
h = UBound(imgSpectrumData, 2): w = UBound(imgSpectrumData, 1)
' Â çàâèñèìîñòè îò ýôôåêòà
Select Case mEffect
Case 0
' ==========Áåç ýôôåêòà (ïðîñòî èçìåíÿåì ïðîçðà÷íîñòü ôîíà)=========
' Îïðåäåëÿåì êîýôôèöèåíò èçìåíåíèÿ àëüôà êîìïîíåíòû
d = Fade * 255
' Ïðîõîä ïî áèòàì ðèñóíêà
For y = 0 To h: For x = 0 To w
' Ïîëó÷àåì àëüôó
a = (((imgSpectrumData(x, y) And &HFF000000) \ &H1000000) And &HFF&)
' Óìåíüøàåì
a = a - d
' Îãðàíè÷èâàåì
If a < 0 Then a = 0
' Âûäåëÿåì òîëüêî êîìïîíåíòû öâåòà
c = imgSpectrumData(x, y) And &HFFFFFF
' Çàïèñûâàåì íàçàä ñ èçìåíåííîé àëüôîé
If a > 127 Then
imgSpectrumData(x, y) = c Or ((a - 256) * &H1000000)
Else: imgSpectrumData(x, y) = c Or (a * &H1000000)
End If
Next: Next
Case 1
' ===========================Ðàçìûòèå================================
' Îïðåäåëÿåì êîýôôèöèåíò èçìåíåíèÿ àëüôà êîìïîíåíòû
d = Fade * 10
' Ïðîõîä ïî áèòàì ðèñóíêà
For y = 0 To h: For x = 0 To w
' Ðàçìûâàåì âíóòðè (1,1,w-1,h-1)
If x > 0 And y > 0 And x < w - 1 And y < h - 1 Then
' Îáíóëÿåì çíà÷åíèÿ íàêîïëåíèÿ êîìïîíåíò
r = 0: g = 0: b = 0: a = 0
' Ïðîõîä ïî ñîñåäíèì ïèêñåëÿì
For dy = -1 To 1: For dx = -1 To 1
' Âûäåëÿåì êàæäóþ êîìïîíåíòó è çàïèñûâàåì â àêêóìóëÿòîðû
c = imgSpectrumData(x + dx, y + dy)
a = a + (((c And &HFF000000) \ &H1000000) And &HFF&)
r = r + (c And &HFF0000) \ &H10000
g = g + (c And &HFF00&) \ &H100
b = b + (c And &HFF)
Next: Next
' Óñðåäíÿåì çíà÷åíèÿ â àêêóìóëÿòîðàõ è óìåíüøàåì àëüôó
r = r \ 9: g = g \ 9: b = b \ 9: a = a \ 9 - d
' Îãðàíè÷èâàåì àëüôó ñíèçó
If a < 0 Then a = 0
' Íàõîäèì çíà÷åíèÿ â
RGB
c = b Or (g * &H100&) Or (r * &H10000)
' Äîáàâëÿåì àëüôó
If a > 127 Then
imgSpectrumData(x, y) = c Or ((a - 256) * &H1000000)
Else: imgSpectrumData(x, y) = c Or (a * &H1000000)
End If
' Èíà÷å îáíóëÿåì (ïîëíîñòüþ ïðîçðà÷íûé)
Else: imgSpectrumData(x, y) = 0
End If
Next: Next
Case 2
' ============================Ãîðåíèå================================
' Îïðåäåëÿåì êîýôôèöèåíò èçìåíåíèÿ àëüôà êîìïîíåíòû
d = Fade * 64
' Êîïèðóåì áèòû ðèñóíêà â áóôåð
Buf = imgSpectrumData
' Âû÷èñëÿåì ñäâèãè è øèðèíó â çàâèñèìîñòè îò îòîáðàæåíèÿ
If mSymmetrical Then o = 0: s = w * 2 Else o = 0.5: s = w
' Ïðîõîä ïî áèòàì ðèñóíêà
For y = 0 To h: For x = 0 To w
' Òðàíñôîðìèðóåì êîîðäèíàòó â çàâèñèìîñòè îò öåíòðà
cx = x / s - o: cy = y / h - 0.5
' Íàõîäèì äëèíó îòíîñèòåëüíî öåíòðà
r = Sqr(cx * cx + cy * cy)
' Íàõîäèì ðåçóëüòòèðóþùèé ïèêñåëü
dx = (cx + o + 0.01 * cx * ((r - 1) / 0.5)) * s
dy = (cy + 0.5 + 0.01 * cy * ((r - 1) / 0.5)) * h
' Íàõîäèì è óìåíüøàåì åãî àëüôó
a = (((Buf(dx, dy) And &HFF000000) \ &H1000000) And &HFF&) - d
' Îãðàíè÷èâàåì àëüôó ñíèçó
If a < 0 Then a = 0
' Âûäåëÿåì òîëüêî êîìïîíåíòû öâåòà
c = Buf(dx, dy) And &HFFFFFF
' Çàïèñûâàåì íàçàä ñ èçìåíåííîé àëüôîé
If a > 127 Then
imgSpectrumData(x, y) = c Or ((a - 256) * &H1000000)
Else: imgSpectrumData(x, y) = c Or (a * &H1000000)
End If
Next: Next
End Select
End Sub