Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 187
  • Last Modified:

Red, Green and Blue

If I open an image using picturebox/imagebox. Is there any way I can get the R, G, and B value of each single pixel?
0
YL
Asked:
YL
1 Solution
 
clifABBCommented:
Yes, using the Point() method will give you the RGB value, the following code will give you the individual values:

  Dim lRes  As Long
  Dim sColor As String
  Dim nRed  As Integer
  Dim nGrn  As Integer
  Dim nBlu  As Integer
 
  lRes = Picture1.Point(1, 1)
  sColor = Right$("000000" & Hex$(lRes), 6)
  nRed = Val("&H" & Mid$(sColor, 5, 2))
  nGrn = Val("&H" & Mid$(sColor, 3, 2))
  nBlu = Val("&H" & Mid$(sColor, 1, 2))
  Debug.Print nRed, nGrn, nBlu

0
 
YLAuthor Commented:
Thanks, clifABB. I will try the codes you sent me later. I was using getBitmap and setBitmap but get only one value for each pixel. (suppose have three). That's why I need your help.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now