Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Interface and Graphics > RGB Values from a picturebox


Reply
 
Thread Tools Display Modes
  #1  
Old 04-02-2005, 09:54 PM
tblakemore tblakemore is offline
Newcomer
 
Join Date: May 2004
Posts: 18
Default RGB Values from a picturebox


Hello,

I have a simple question. I have a form and a picturebox. All I want to do is when I mouseover the picturebox, have the pixels RGB value that is under the cursor displayed in a textbox.

However, I cannot find any documentation to do this.

I have tried --> picture1.point(X,Y) <-- to retrieve the color but it returns the result as a long number.

Does anyone know how to convert this number to an RGB or if there is another function to retrieve the RGB of an image a cursor is under.
Reply With Quote
  #2  
Old 04-02-2005, 10:12 PM
Gruff's Avatar
Gruff Gruff is offline
Bald Mountain Survivor

Super Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA
Posts: 5,882
Default

Code:
Option Explicit Dim Color As Long Dim Red As Byte Dim Green As Byte Dim Blue As Byte Color = Picture1.Point(X, Y) Red = Color And &HFF Green = (Color And &HFF00&) \ &H100& Blue = (Color And &HFF0000) \ &H10000 Msgbox Red & "//" & Green & "//" & Blue
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
  #3  
Old 04-02-2005, 11:32 PM
tblakemore tblakemore is offline
Newcomer
 
Join Date: May 2004
Posts: 18
Default

Thank you very much Gruff. The code works perfectly!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->