By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,193 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Color-BackColor

P: n/a
Given BackColor of

BGC = RGB(x,y,z)

is there a function, procedure or rule of thumb based on the values of x,y
and z

which will indicate which of black or white

is likely to stand out more as a ForeColor?

.....

If one allows colors for ForeColor "NOT RGB(x,y,z)" seems to provide
contrast for those colors which are bright or dark, but NOT grey seems to
result in something pretty close to grey.

That is Not RGB(128,128,128) = RGB(127,127,127) (actually as a long it
slams an &HFF in the 4 hole but that's irrelevant here, I think.)

I suppose there is some rule of thumb based on the value of BGC ... but
I'll see if anyone has experience with this before I annoy my household
with ... look at this combination ... which is clearer???? all day.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Lyle Fairfield <Mi************@Invalid.Com> wrote in
news:Xn*******************@130.133.1.4:
That is Not RGB(128,128,128) = RGB(127,127,127) (actually as a long it
slams an &HFF in the 4 hole but that's irrelevant here, I think.)


While it may be irrelevant for the purposes of this discussion, it seems
setthing the last bit in this byte transforms the rgb color to something else
.... perhaps a windows system color ... where the other values map to an index
rather than directly affecting color ... maybe this is good reason not to use
NOT.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

P: n/a
Lyle Fairfield <Mi************@Invalid.Com> wrote in message news:<Xn*******************@130.133.1.4>...
Given BackColor of

BGC = RGB(x,y,z)

is there a function, procedure or rule of thumb based on the values of x,y
and z

which will indicate which of black or white

is likely to stand out more as a ForeColor?

....

If one allows colors for ForeColor "NOT RGB(x,y,z)" seems to provide
contrast for those colors which are bright or dark, but NOT grey seems to
result in something pretty close to grey.

That is Not RGB(128,128,128) = RGB(127,127,127) (actually as a long it
slams an &HFF in the 4 hole but that's irrelevant here, I think.)

I suppose there is some rule of thumb based on the value of BGC ... but
I'll see if anyone has experience with this before I annoy my household
with ... look at this combination ... which is clearer???? all day.

Isn't the colour value (colorref) supposed to indicate the
'brightness' of a colour? As you're not looking for an 'opposite'
colour (you said black or white) why not just go ForeColor Black for
BGC >= 8421504 which is RGB(128,128,128)and White for BGC < 8421504?
Nov 12 '05 #3

P: n/a
jo*******@btinternet.com (Jon Lewis) wrote in
news:3f**************************@posting.google.c om:
Lyle Fairfield <Mi************@Invalid.Com> wrote in message
news:<Xn*******************@130.133.1.4>...
Given BackColor of

BGC = RGB(x,y,z)

is there a function, procedure or rule of thumb based on the values of
x,y and z

which will indicate which of black or white

is likely to stand out more as a ForeColor?

....

If one allows colors for ForeColor "NOT RGB(x,y,z)" seems to provide
contrast for those colors which are bright or dark, but NOT grey seems
to result in something pretty close to grey.

That is Not RGB(128,128,128) = RGB(127,127,127) (actually as a long it
slams an &HFF in the 4 hole but that's irrelevant here, I think.)

I suppose there is some rule of thumb based on the value of BGC ... but
I'll see if anyone has experience with this before I annoy my household
with ... look at this combination ... which is clearer???? all day.

Isn't the colour value (colorref) supposed to indicate the
'brightness' of a colour? As you're not looking for an 'opposite'
colour (you said black or white) why not just go ForeColor Black for
BGC >= 8421504 which is RGB(128,128,128)and White for BGC < 8421504?


Well such a rule may work in practical terms and the colors may "look"
right, which, I suppose, is what we want, but the rule doesn't "look"
right, as all 128's are not equal, that is the red 128 is 128 but the green
128 is 128 * 255 = 32640 while the blue 128 is 128 * 65280 = 8355840.

My current rule of thumb is:

With r
Do While Not .EOF
c(0) = CLng("&H" & Right(!ColorRGBBytes, 6)) 'colors are stored
as # plus six hex digits
c(1) = ((c(0) And 255) / 2 ^ 0 + (c(0) And 65280) / 2 ^ 8 + (c
(0) And 16711680) / (2 ^ 16))
If c(1) < 128 Then
!ForeColorRGBBytes = "#ffffff"
Else
!ForeColorRGBBytes = "#000000"
End If
.MoveNext
Loop
.UpdateBatch
End With

which results,,in what I hope are the darkest one sixth of the colors,
having a white forecolor and the rest, black.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.