Problem with RGB

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? :-)))
LVL 5
Julian_KAsked:
Who is Participating?
 
rspahitzConnect With a Mentor Commented:
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
 
nichiaCommented:
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
 
Julian_KAuthor Commented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Richie_SimonettiIT OperationsCommented:
That's not a bad idea! You could do it with mspaint also.
0
 
Richie_SimonettiIT OperationsCommented:
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
 
Julian_KAuthor Commented:
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
 
PaulHewsCommented:
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
 
ashunigamCommented:
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
 
nichiaCommented:
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
 
Julian_KAuthor Commented:
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
 
Julian_KAuthor Commented:
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
 
Julian_KAuthor Commented:
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
 
rspahitzCommented:
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
 
DanRollinsCommented:
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
 
Julian_KAuthor Commented:
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
 
DanRollinsCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.