[Filter Tutorial]
By LCSBSSRHXXX
Hey every one I wrote this tutorial because it was pretty hard to figure out how to make filters for my paint program, I got a little help from my dad with some of the ways to process an image, and some I figured out by going into photo shop and finding the differences from the RGB values in the original picture and the return picture
and I spent a few days expermenting and writing filters from trial and error and from thinking.
Grey Scale
The average of the RGB values then the avrage of the pixel's RGB apply that value to the RGB values
Invert Colors
Subtract The RGB values from 255.
Birghten
Add to the RGB value.
Darken
Subtract to the RGB value.
Dodge
Multiply the RGB value by 2.
Burn
Divide the RGB value by 2.
Noise
Add or subtract a random number from the RGB values.
Here Are Two In Depth Tutorials For Making A Filter, With Examples
Grey Scale
grey scale is the color range from black (RGB(0,0,0)) to white (RGB(255,255,255)) if you want to convert an image
to grey scale you need to get all the RGB values equal, the method I used to convert a image to grey scale is:
[1] Get Images Pixels
[2] Set a variable to the value of the average of the pixels RGB values set a variable to it (greycolor = R + G + B / 3)
[3] Set a pixel with "greycolor" (The variable you set the average of the pixel's RGB) over the old pixel, this gets the
pixel into grey scale
example:
Code:
Dim greycolor as Integer
Private Declare Function SetPixel Lib "Gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Sub Invert()
For Y = 0 To (Picture.Height / Screen.TwipsPerPixelY)
For X = 0 To (Picture1.Width / Screen.TwipsPerPixelX)
R =Picture1.Point(X, Y) And 255
G = (Picture1.Point(X, Y) And 65280) / 256
B = (Picture1.Point(X, Y) And 16711680) / 65535
greycolor = (R + G + B) / 3
SetPixel Picture1.hdc, X, Y, RGB(greycolor, greycolor, greycolor)
Next X
Next Y
End Sub
Invert Colors
Inverting colors takes a image and turns the colors to oppisite colors, or inverted colors. To invert an image I do this:
[1] Get Images Pixels
[2] Set a pixel with RGB(255 - R, 255 - G, 255 - B)
example:
Code:
Private Declare Function SetPixel Lib "Gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Sub Invert()
For Y = 0 To (PicBox.Height / Screen.TwipsPerPixelY)
For X = 0 To (Picture1.Width / Screen.TwipsPerPixelX)
R =Picture1.Point(X, Y) And 255
G = (Picture1.Point(X, Y) And 65280) / 256
B = (Picture1.Point(X, Y) And 16711680) / 65535
greycolor = (R + G + B) / 3
SetPixel Picture1.hdc, X, Y, RGB(255 - R, 255 - G, 255 - B)
Next X
Next Y
End Sub