Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Visual Basic [VB] (http://www.go4expert.com/articles/visual-basic-tutorials/)
-   -   Counting Red and Black Pixels in VB6 (http://www.go4expert.com/articles/counting-red-black-pixels-vb6-t4535/)

gddwms 4Jun2007 01:41

Counting Red and Black Pixels in VB6
 
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
:)

shabbir 4Jun2007 08:06

Re: Counting Red and Black Pixels in VB6
 
Really Nice one.


All times are GMT +5.5. The time now is 09:46.