8 bit grayscale?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Omelskitot
    New Member
    • Aug 2012
    • 10

    8 bit grayscale?

    Is this a code for generating 8 bit grayscale??
    Code:
    1.Private Sub CMDGRAY_Click()
    2.Dim X As Integer, Y As Integer
    3.Dim R As Integer, G As Integer, B As Integer, A As Integer
    4.For X = 1 To ubx
    5.For Y = 1 To uby
    6.pixels(X, Y) = Picture1.Point(X, Y)
    7.Next Y
    8.Next X
    9. 
    10.For X = 1 To ubx
    11.For Y = 1 To uby
    12.R = pixels(X, Y) And &HFF
    13.G = ((pixels(X, Y) And &HFF00) / &H100) Mod &H100
    14.B = ((pixels(X, Y) And &HFF0000) / &H10000) Mod &H100
    15.A = (R + G + B) / 3
    16.pixels(X, Y) = RGB(A, A, A)
    17.Next Y
    18.Next X
    19.For X = 1 To ubx
    20.For Y = 1 To uby
    21.Picture2.PSet (X, Y), pixels(X, Y)
    22.Next Y
    23.Next X
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    It should be relatively easy to see if that's the case by running the code.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Note that for a better grayscale the colours aren't given equal weight. In other words, red, green and blue don't all contribute the same amount to the darkness of the resulting gray.

      I forget the exact proportions, but the ColourToGreysca le function in this article looks as though it may help.

      Comment

      Working...