Counting Red and Black Pixels in VB6

Discussion in 'Visual Basic [VB]' started by gddwms, Jun 3, 2007.

  1. gddwms

    gddwms New Member

    Joined:
    Jun 3, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Put on form Picture Box control and button. Set property ScaleMode to 3-Pixel and post this code:

    Code:
    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
    :)
     
    Last edited by a moderator: Jun 4, 2007
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Really Nice one.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice