Solved

Problem with RGB

Posted on 2002-06-13
16
460 Views
Last Modified: 2010-05-02
Hi, Experts.

Here is my Problem... to understand me better, furst put this code on a Command1_Click event:

Private Sub Command1_Click()
    Me.Line (0, 0)-(1000, 1000), &HFF0000, BF
    Me.Line (1000, 0)-(2000, 1000), &HFF2020, BF
    Me.Line (0, 1000)-(1000, 2000), &HBF0000, BF
End Sub

Here, as you see, I paint 3 boxes.
First is blue,
second is blue, but lighter,
third is blue, darker.

If You calculate the sum of RGB for the lighter and the darker, their absolute values of (difference from the blue) are equal . But... it does not seem so to my eyes.

The problem is, that the lighter does not seem to be as bright, as the darker is dark. :-(

Let's say I'm trying to draw 3d borders around a box.

So, do you have any idea how can I "Shift" some color in both directions (ligter, darker), so the visual perception is ok?

Or is it that just my display is not ok? :-)))
0
Comment
Question by:Julian_K
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
  • 2
  • +4
16 Comments
 
LVL 3

Expert Comment

by:nichia
ID: 7075841
The reason that the light blue is not as "bright" is that you have desaturated it by adding red and green.  The other colors have no R-G component, and so look more saturated.

Instead of trying to do this by the numbers, I suggest picking your colors from the color picker (by eye), then coding in the values based on what *looks* right to you.

Hope it helps!
0
 
LVL 5

Author Comment

by:Julian_K
ID: 7075885
Hello, nichia.
I need EXACTLY "by the numbers" as you say. That's because the color may change. So I need to change the brighter and the darker border accordingly to it.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7075922
That's not a bad idea! You could do it with mspaint also.
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7075926
what nichia saids is:
Use color picker to know which are the long values for that colors and write them down in the code.
You could use the picker from the form itself.
0
 
LVL 5

Author Comment

by:Julian_K
ID: 7075932
Richie, are you kidding or what?
The question is serious. I need this colors to be calculated. I have tried it with different algorythms, and they seem to work fine on some colors which are mixture of RGB, but can not handle with some other colors. I'm DESPERATE. HELP :-(
0
 
LVL 38

Expert Comment

by:PaulHews
ID: 7076176
Convert from HSL to RGB
http://abstractvb.com/code.asp?F=50&P=1&A=926

Convert from RGB to HSL
http://abstractvb.com/code.asp?F=50&P=1&A=927

What you need to do is convert your RGB color to HSL (Hue, Saturation and Luminance) then change the luminance value to make it brighter or darker and convert back to RGB to display that color.
0
 
LVL 3

Expert Comment

by:ashunigam
ID: 7076203
Is it what you want?
   Me.Line (0, 0)-(1000, 1000), RGB(0, 0, 255), BF
   Me.Line (1000, 0)-(2000, 1000), RGB(0, 0, 225), BF
   Me.Line (0, 1000)-(1000, 2000), RGB(0, 0, 150), BF
0
 
LVL 3

Expert Comment

by:nichia
ID: 7076257
The color model makes no difference in this case: the only way to lighten a pure color is to reduce its saturation and the only way to darken it is to bring down the brightness (lightness).  This is exactly what you did and did not like the results.

0
 
LVL 22

Accepted Solution

by:
rspahitz earned 300 total points
ID: 7076321
One other problem in the mix is that, as you say, the darker stuff gets darker faster.

For example, if you take Pure blue, &HFF0000 and cut it to half its intensity, &H800000, it looks quite dark (navy).

If you further take half that intensity, &H400000, it becomes almost indistinguishable from black whereas if you added half the intensity, &HC00000, it's a nice shade of blue.

This problem is what I'd call a human perception problem.  That is, our eyes are designed to see very subtle shades of colors, but only in a certain range (50% to 100% light intensity on monitors.  If you were a cat, you'd likely have a different range since they see better in the dark.

Anyway, what I've found works well with color ranges is to subtract scaled percentages when going darker.  For example, subtract 1% to go darker, then 2%, 4%, 8%, etc.  (or something like that.)  I don't have an exact formula handy.)

On the lighter side, as mentioned, you need to increase the red and green components in equal propertions to give the appearance of getting lighter.  Eventually, you'll get 100% of each color and have white.
0
 
LVL 5

Author Comment

by:Julian_K
ID: 7077860
First, I want to thank to all of You.

ashunigam, I will reject your answer. Please read more carefully before answering...

nichia, you're correct, and I thank You, but this is all in theory. I need some example code.


PaulHews, thanks for the links. The functions that You provided, return more correct values, than mine.


Yet, here stays the "Human Perception" factor, as rspahitz said, and that cuts my brain. :-(

So, the 150 points will go to PaulHews, he deserves them.

(PaulHews, I'll open another empty question for you to get your points.)


rspahitz, You got my question :-)
As for the so-called "Human Factor", You, (or anyone else) If You come with some idea, that is more defined, I will award You double (300pts), because THIS IS the problem, I had in mind, while writing the question.

I'm just not sure if this problem could be solved so easily...
0
 
LVL 5

Author Comment

by:Julian_K
ID: 7077864
ashunigam, as I said, I'm rejecting your answer. I'm Sorry, but what you provide as an answer is far away from the problem.
0
 
LVL 5

Author Comment

by:Julian_K
ID: 7077865
As I said, I increase the value of this question to 300 pts., but now the topic is how to avoid that "Human Factor".
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 7078927
I'd say that the best way to evaluate the "human factor" is to start by observing a specific color in the color bar.

To do this, pick any VB form's forecolor (or any other color property.)  In the dropdown list select the palette and right-click on one of the boxes at the bottom.  This opens a "Define Color" window (similar to the color-picker in Windows.)

Zero-out the Red and Green components and notice where the arrow appears next to the vertical brightness bar (just above the RGB color values.)  It right in the middle.  Anything below this is a darker shde of blue.  Anything above this is a brighter shade of red and green.  (Drag the arrow to observe this effect.)

I think this is the approach you need to use.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7900202
Hi Julian_K,
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:

    Split points between: PaulHews and rspahitz

Julian_K, 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
 
LVL 5

Author Comment

by:Julian_K
ID: 7901174
Hi, DanRollins.

1. I awarded PaulHews, opening a special question for him (with topic "Points for PaulHews") and he got his points.
This is because he gave me some extra information I was not asking for, but I found it valuable.
============================
2. My Question was: "...So, do you have any idea how can I "Shift" some color in both directions (ligter, darker), so the visual perception is ok?"
============================
I do not think anybody answered my question (at least with some usefull code or function or any other kind of exact algorythm for calculation).

3. If someone MUST have the points, I prefer giving them to rspahitz

Thank you.
Julian
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7902070
Thanks for returning to help clean up this old question.

If you want to award points to rspahitz, click the [Accept comment as answer] link near his comment.

If you don't want to award any points, say so and a Moderator will handle it in about 7 days (to be honest, I think these experts deserve some credit!  PaulHews comment was brilliant, and rspahitz did provide help with your SECOND question).

-- Dan
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month9 days, 7 hours left to enroll

624 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