Solved

Red, Green and Blue

Posted on 1998-08-28
2
180 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
ID: 1431608
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
ID: 1431609
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

770 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