Skip to content

Planet-Source-Code/jared-collums-tv-lines-image-filter__1-25300

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 

Repository files navigation

TV Lines Image Filter

Description

This code puts lines over a picture box's picture. You can set it's opacity, and it's direction.

More Info

PictBox, the picture box to manipulate. optional Opacity. This controls how transparent/solid the lines are. The value works best with a value 1-100. And direction...wich sets the lines horizontal(1) or vertical(2).

For this to work, the picturebox must have AutoRedraw set, and it's scalemode must be pixels.

if it's a very big image, it might be a tiny bit slow.

Submitted On
By Jared Collums
Level Intermediate
User Rating 4.7 (14 globes from 3 users)
Compatibility VB 6.0
Category Graphics
World Visual Basic
Archive File

API Declarations

Public Declare Function SetPixel Lib "GDI32" (ByVal HDC As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Public Declare Function GetPixel Lib "GDI32" (ByVal HDC As Long, ByVal X As Long, ByVal Y As Long) As Long

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published