TV Lines Image Filter
This code puts lines over a picture box's picture. You can set it's opacity, and it's direction.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
Public Sub TVLines(PictBox As PictureBox, Optional Direction As Integer, Optional Opacity As Long) Dim i As Long, k As Long, r As Long, g As Long, b As Long, pixel As Long, pix As Long If IsMissing(Opacity) Then Opacity = 25 If IsMissing(Direction) Then Direction = 1 Opacity = Opacity * 2.55 Opacity = Round(Opacity) For k = 0 To PictBox.ScaleHeight - 1 For i = 0 To PictBox.ScaleWidth - 1 'get current pixel pixel = GetPixel(PictBox.HDC, i, k) 'get rgb values of the pixel r = TakeRGB(pixel, 0) g = TakeRGB(pixel, 1) b = TakeRGB(pixel, 2) 'the code alternates lightness/darkness each line If Direction = 1 Then pix = k Else pix = i End If If pix / 2 = Int(pix / 2) Then r = IIf(r - Opacity < 0, 0, r - Opacity) g = IIf(g - Opacity < 0, 0, g - Opacity) b = IIf(b - Opacity < 0, 0, b - Opacity) Else r = IIf(r + Opacity > 255, 255, r + Opacity) g = IIf(g + Opacity > 255, 255, g + Opacity) b = IIf(b + Opacity > 255, 255, b + Opacity) End If 'set new pixel SetPixel PictBox.HDC, i, k, RGB(r, g, b) Next i PictBox.Refresh Next k PictBox.Refresh End Sub 'just a function to get rgb values of a pixel 'I borrowed it from Jongmin Baek's Drawer (an exellect program, btw) Function TakeRGB(Colors As Long, Index As Long) As Long IndexColor = Colors Red = IndexColor - Int(IndexColor / 256) * 256: IndexColor = (IndexColor - Red) / 256 Green = IndexColor - Int(IndexColor / 256) * 256: IndexColor = (IndexColor - Green) / 256 Blue = IndexColor If Index = 0 Then TakeRGB = Red If Index = 1 Then TakeRGB = Green If Index = 2 Then TakeRGB = Blue End Function
Original Comments (3)
Recovered from Wayback Machine