Counting Red and Black Pixels in VB6

gddwms's Avatar author of Counting Red and Black Pixels in VB6
This is an article on Counting Red and Black Pixels in VB6 in Visual Basic [VB].
Rated 5.00 By 1 users
Put on form Picture Box control and button. Set property ScaleMode to 3-Pixel and post this code:

Code: VB
Private Sub Command1_Click()
Dim arr(1000, 1000) As Integer
Dim i
Dim y
Dim iSumRed As Integer
Dim iSumBlack As Integer

iSumRed = 0
iSumBlack = 0
For i = 0 To Pict.Picture.Width
    For y = 0 To Pict.Picture.Height
        If Pict.Point(i, y) = vbRed Then
            iSumRed = iSumRed + 1
        End If
        If Pict.Point(i, y) = vbBlack Then
            iSumBlack = iSumBlack + 1
        End If
    Next
Next
Debug.Print "Black :" & iSumBlack
Debug.Print "Red :" & iSumRed
End Sub
This code counts Black and Red pixels in PictureBox

Go4Expert Founder
4Jun2007,08:06   #2
shabbir's Avatar
Really Nice one.