Solved

Problem with RGB

Posted on 2002-06-13
16
454 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
  • 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
 
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

760 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

17 Experts available now in Live!

Get 1:1 Help Now