Solved

how to use picture1.point?

Posted on 2002-05-16
8
651 Views
Last Modified: 2010-05-18
I'm using this:

MsgBox Picture1.Point(4, 4)

and I get a Long number:
7745800

How can I get the Red,Green and Blue value?
0
Comment
Question by:wcoka
8 Comments
 
LVL 2

Expert Comment

by:Crin
ID: 7015026
Hi,

For Red: Value Mod 256
For Green: (Value \ 256) Mod 256
For Blue: (Value \ 65536) Mod 256

Sincerely,
Crin
0
 
LVL 2

Accepted Solution

by:
Crin earned 50 total points
ID: 7015031
Hehe...
Actually, latest formula doesn't require mod operation...

so, it will look like
For Blue: Value \ 65536

(Where Value is a result of the Point function)

Sincerely,
Crin
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7015173
Or convert to hex first, then pull out the piece you need:

Private Sub Command1_Click()
  Dim strPointColor As String
strPointColor = Format$(Hex$(Picture1.Point(4, 4)), "000000")

Debug.Print "Blue component is " & Val("&H" & Left$(strPointColor, 2))
Debug.Print "Green component is " & Val("&H" & Mid$(strPointColor, 3, 2))
Debug.Print "Red component is " & Val("&H" & Right$(strPointColor, 2))
Debug.Print
End Sub
0
 

Author Comment

by:wcoka
ID: 7015685
Hey guys, wich of thos two answers is faster? which way?

Also, what does that long number that comes from the point method means?

Thanks a lot
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:rspahitz
ID: 7016660
Crin's is probably fasters since it doesn't convert back and forth between strings.

That long number is Window's way of keeping track of colors.  It actually represents the three components of a color monitor--Red, Green, and Blue pixels.  Since each can have a computer-defined range of 0 (off) to 255 (full intensity) they had the choice of forcing you to take the pixels individually to determine the color, or combine it; they chose to combine it.

For example, when you see yellow on the screen, your eye is actually tricked into it by seeing bright red combined with bright green.

That long number is actually the computer storing the pixel values in three consecutive bytes which, when interpreted in decimal, looks like a long number that you see.  When interpreted in hexadecimal, it becomes much clearer what each component represents.  Both examples above take different approaches to interpreting the number's 3 bytes.
0
 
LVL 2

Expert Comment

by:Crin
ID: 7022221
Hi.

rspahitz's answer regarding long number is almost right.

Actually, *four* bytes used to store each pixel colour: three to store each channel intensity and one to define custom colors.

For example, there are system values for following colors: scroll bars, desctop, active title bar, inactive title bar etc. And you can use these settings to specify form background color.

So, if you get long number that represents color:
00 xx yy zz (smallest goes last) - 00 means that it is custom color, xx - blue component value, yy - green component value, and zz - red component value.
80 (hexadecimal value) in place of 00 will mean that system will fill form or any other control to specified system color.

Also, my way will work faster since string operations are most time consuming in VB for simplest data types.

Sincerely,
Crin.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7817744
Hi wcoka,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept Crin's comment(s) as an answer.

wcoka, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7909695
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

863 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

20 Experts available now in Live!

Get 1:1 Help Now