Solved

Red, Green and Blue

Posted on 1998-08-28
2
177 Views
Last Modified: 2010-04-30
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
Comment
Question by:YL
2 Comments
 
LVL 6

Accepted Solution

by:
clifABB earned 100 total points
Comment Utility
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
 

Author Comment

by:YL
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now