|
|
Title | Convert almost white pixels to white |
Description | This example shows how to convert almost white pixels to white in Visual Basic 6. |
Keywords | pixels, color, convert, color conversion |
Categories | Graphics |
|
|
This program cleans up almost white pixels. It loops over the pixels in an image. If a pixel's total red, green, and blue components is greater than 3 * 128, the program makes the pixel white.
|
|
Private Sub Form_Load()
Dim file_name As String
Dim X As Integer
Dim Y As Integer
Dim r As Integer
Dim g As Integer
Dim b As Integer
picOriginal.AutoRedraw = True
For Y = 0 To picOriginal.ScaleHeight - 1
For X = 0 To picOriginal.ScaleWidth - 1
UnRGB picOriginal.Point(X, Y), r, g, b
If r + g + b > 3 * 128 Then
picOriginal.PSet (X, Y), vbWhite
End If
Next X
Next Y
picOriginal.Picture = picOriginal.Image
file_name = App.Path
If Right$(file_name, 1) <> "\" Then file_name = _
file_name & "\"
SavePicture picOriginal.Picture, file_name & "clean.bmp"
End Sub
|
|
My book Visual Basic Graphics Programming shows how to apply much more sophisticated filtering methods to images.
|
|
|
|
|
|