1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,292
    Likes Received:
    365
    Trophy Points:
    83
    Really Nice one.
     

Share This Page