Discussion:
retrieving 16-bit depth system color
(too old to reply)
Frederiek
2006-02-23 16:37:06 UTC
Permalink
Hello,

I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?

I already wrote some code to convert 24bit to 16bit color, but the
result doesn't match exactly, there's a slight difference. E.g. if I
fill a window client area with the converted COLOR_3DFACE, it doesn't
exactly match the color of the surrounding window. Before I start
spending time on looking what the problem is, I thought I better look
for any existing function that does the work for me.

Regards,

Frederiek
James Brown [MVP]
2006-02-23 18:29:33 UTC
Permalink
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
I already wrote some code to convert 24bit to 16bit color, but the
result doesn't match exactly, there's a slight difference. E.g. if I
fill a window client area with the converted COLOR_3DFACE, it doesn't
exactly match the color of the surrounding window. Before I start
spending time on looking what the problem is, I thought I better look
for any existing function that does the work for me.
Regards,
Frederiek
GDI is device-independent, you don't need to be concerned with bit-depths
when you are filling your client-area with a colour.

Just specify real COLORREF values when creating brushes, fills etc and GDI
will do all the necessary conversion for you.

James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
Frederiek
2006-02-24 12:13:38 UTC
Permalink
Post by James Brown [MVP]
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
[snip]
Post by James Brown [MVP]
Post by Frederiek
Frederiek
GDI is device-independent, you don't need to be concerned with bit-depths
when you are filling your client-area with a colour.
Just specify real COLORREF values when creating brushes, fills etc and GDI
will do all the necessary conversion for you.
James
I am not using the GDI functions. My intent is not exactly to fill a
window client area with the COLOR_3DFACE color. I load a 32bit color
bitmap into memory. From there I copy the pixeldata to display memory.
But before the pixeldata is copied, I convert the 32bit data to 16bit
if the display mode is highcolor, i.e. 16bit. The bitmap also contains
3 RGB colors that I look for after the bitmap is loaded first in
memory. Another thing that I do before copying the pixels to the
backbuffer is to replace the pixeldata representing these colors with
the COLOR_3DFACE, COLOR_3DLIGHT and COLOR_3DSHADOW RGB colors. When in
32bit mode there's no problem since GetSysColor() returns the exact
24bit color values, i.e. the colors match exactly after conversion.
However, I when in 16bit mode I need to convert the result of
GetSysColor() to a 16bit value.
So I was wondering if there's a function or a standard method for
retrieving the exact 16 bit RGB system colors.

What I do currently is to determine the RGB bitmask used by the current
display mode. In 16bit mode this is mostly 5bit red, 6bit green and
5bit blue. Then I multiply for every color fraction the 8bit value from
the bitmap by the maximum target 16bit color fraction value, and divide
the result by the maximum 8bit value (i.e. 256).

E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b

Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.

I suppose there is no 16bit alternative to GetSysColor?

Regards,

Frederiek
Matt
2006-02-24 14:10:51 UTC
Permalink
Post by Frederiek
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
Well, obviously you're going to lose some accuracy converting a 24 bit
value to a 16 bit value. There's no way around that. You might want
to try (red_32b * (max_red_16b + 1)) / (max_red_32b + 1), though, to
keep the max_* variables powers of 2, if they aren't already. That
might help a little.

Matt
Frederiek
2006-02-24 18:55:57 UTC
Permalink
Post by Matt
Post by Frederiek
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
Well, obviously you're going to lose some accuracy converting a 24 bit
value to a 16 bit value. There's no way around that. You might want
to try (red_32b * (max_red_16b + 1)) / (max_red_32b + 1), though, to
keep the max_* variables powers of 2, if they aren't already. That
might help a little.
Matt
It doesn't matter that I am loosing color information. It is not my
intention to get exactly the same color in 16bit color mode as I get in
32bit color mode. The idea is to determine the 16bit color value of
certain system colors when in 16bit color mode. Since in 16bit color
mode, these system colors are stored in display memory as 16 bit
values, in theory it is possible to get an exact match after
calculation.

The maximum values are indeed always powers of 2. E.g. when the 16bit
color mode has the format 5.6.5 (red.green.blue), then the maximum
value of red is 32, i.e 2 to the power of 5.

Regards,

Frederiek
Alexander Grigoriev
2006-02-25 04:12:08 UTC
Permalink
unsigned short RGB565 = ((R & 0xF8) << 11) | ((G & 0xFC) << 3) | ((B & 0xF8)
Post by Frederiek
Post by Matt
3);
Post by Frederiek
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
Well, obviously you're going to lose some accuracy converting a 24 bit
value to a 16 bit value. There's no way around that. You might want
to try (red_32b * (max_red_16b + 1)) / (max_red_32b + 1), though, to
keep the max_* variables powers of 2, if they aren't already. That
might help a little.
Matt
It doesn't matter that I am loosing color information. It is not my
intention to get exactly the same color in 16bit color mode as I get in
32bit color mode. The idea is to determine the 16bit color value of
certain system colors when in 16bit color mode. Since in 16bit color
mode, these system colors are stored in display memory as 16 bit
values, in theory it is possible to get an exact match after
calculation.
The maximum values are indeed always powers of 2. E.g. when the 16bit
color mode has the format 5.6.5 (red.green.blue), then the maximum
value of red is 32, i.e 2 to the power of 5.
Regards,
Frederiek
James Brown [MVP]
2006-02-24 14:27:52 UTC
Permalink
Post by Frederiek
Post by James Brown [MVP]
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
[snip]
Post by James Brown [MVP]
Post by Frederiek
Frederiek
GDI is device-independent, you don't need to be concerned with bit-depths
when you are filling your client-area with a colour.
Just specify real COLORREF values when creating brushes, fills etc and GDI
will do all the necessary conversion for you.
James
I am not using the GDI functions. My intent is not exactly to fill a
window client area with the COLOR_3DFACE color. I load a 32bit color
bitmap into memory. From there I copy the pixeldata to display memory.
But before the pixeldata is copied, I convert the 32bit data to 16bit
if the display mode is highcolor, i.e. 16bit. The bitmap also contains
3 RGB colors that I look for after the bitmap is loaded first in
memory. Another thing that I do before copying the pixels to the
backbuffer is to replace the pixeldata representing these colors with
the COLOR_3DFACE, COLOR_3DLIGHT and COLOR_3DSHADOW RGB colors. When in
32bit mode there's no problem since GetSysColor() returns the exact
24bit color values, i.e. the colors match exactly after conversion.
However, I when in 16bit mode I need to convert the result of
GetSysColor() to a 16bit value.
So I was wondering if there's a function or a standard method for
retrieving the exact 16 bit RGB system colors.
What I do currently is to determine the RGB bitmask used by the current
display mode. In 16bit mode this is mostly 5bit red, 6bit green and
5bit blue. Then I multiply for every color fraction the 8bit value from
the bitmap by the maximum target 16bit color fraction value, and divide
the result by the maximum 8bit value (i.e. 256).
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
I suppose there is no 16bit alternative to GetSysColor?
Regards,
Frederiek
how exactly are you accessing display memory? unless you give specifics
noone can offer any suggestions other than "windows is device-independent"

James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
Frederiek
2006-02-24 19:09:37 UTC
Permalink
Post by James Brown [MVP]
Post by Frederiek
Post by James Brown [MVP]
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
[snip]
Post by James Brown [MVP]
Post by Frederiek
Frederiek
GDI is device-independent, you don't need to be concerned with bit-depths
when you are filling your client-area with a colour.
Just specify real COLORREF values when creating brushes, fills etc and GDI
will do all the necessary conversion for you.
James
I am not using the GDI functions. My intent is not exactly to fill a
window client area with the COLOR_3DFACE color. I load a 32bit color
bitmap into memory. From there I copy the pixeldata to display memory.
But before the pixeldata is copied, I convert the 32bit data to 16bit
if the display mode is highcolor, i.e. 16bit. The bitmap also contains
3 RGB colors that I look for after the bitmap is loaded first in
memory. Another thing that I do before copying the pixels to the
backbuffer is to replace the pixeldata representing these colors with
the COLOR_3DFACE, COLOR_3DLIGHT and COLOR_3DSHADOW RGB colors. When in
32bit mode there's no problem since GetSysColor() returns the exact
24bit color values, i.e. the colors match exactly after conversion.
However, I when in 16bit mode I need to convert the result of
GetSysColor() to a 16bit value.
So I was wondering if there's a function or a standard method for
retrieving the exact 16 bit RGB system colors.
What I do currently is to determine the RGB bitmask used by the current
display mode. In 16bit mode this is mostly 5bit red, 6bit green and
5bit blue. Then I multiply for every color fraction the 8bit value from
the bitmap by the maximum target 16bit color fraction value, and divide
the result by the maximum 8bit value (i.e. 256).
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
I suppose there is no 16bit alternative to GetSysColor?
Regards,
Frederiek
how exactly are you accessing display memory? unless you give specifics
noone can offer any suggestions other than "windows is device-independent"
James
I am using DirectX. DirectX offers a way to directly access video
memory. But in essence I was looking for a win32 function that is able
to convert 24bit color values to 16bit values. But such a win32
function probably does not exist...? So I guess I will have to do the
conversion myself.

Kind regards,

Frederiek
James Brown [MVP]
2006-02-24 19:46:42 UTC
Permalink
Post by Frederiek
I am using DirectX. DirectX offers a way to directly access video
memory. But in essence I was looking for a win32 function that is able
to convert 24bit color values to 16bit values. But such a win32
function probably does not exist...? So I guess I will have to do the
conversion myself.
Kind regards,
Frederiek
ok I see the issue now.. and AFAIK there is no built-in function to convert
to/from RGB values. The way I would do this would be to indentify the
color-format you are in (i.e. 5-6-5 or 5-5-5) and then do some simple math
to reduce the colour-depth.

If you have 8bit colour-values and you need to go to 5-5-5, simply
right-shift your values by 3:

COLORREF col32 = GetSysColor(COLOR_3DFACE);

int red = GetRValue(col) >> 3;
int green = GetGValue(col) >> 3;
int blue = GetBValue(col) >> 3;

then make your 16bit value from here:

WORD col16 = (red << 10) | (green << 5) | blue;

if you have 5-6-5 then obviously you only << the green value by 2

I suspect you are seeing incorrect colours because think you are in one mode
(5-5-5) when you should be dealing with another (5-6-5), and one of the
colour-channels is incorrect.

James
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
Frederiek
2006-03-03 11:53:44 UTC
Permalink
Post by James Brown [MVP]
Post by Frederiek
I am using DirectX. DirectX offers a way to directly access video
memory. But in essence I was looking for a win32 function that is able
to convert 24bit color values to 16bit values. But such a win32
function probably does not exist...? So I guess I will have to do the
conversion myself.
Kind regards,
Frederiek
ok I see the issue now.. and AFAIK there is no built-in function to convert
to/from RGB values. The way I would do this would be to indentify the
color-format you are in (i.e. 5-6-5 or 5-5-5) and then do some simple math
to reduce the colour-depth.
If you have 8bit colour-values and you need to go to 5-5-5, simply
COLORREF col32 = GetSysColor(COLOR_3DFACE);
int red = GetRValue(col) >> 3;
int green = GetGValue(col) >> 3;
int blue = GetBValue(col) >> 3;
WORD col16 = (red << 10) | (green << 5) | blue;
if you have 5-6-5 then obviously you only << the green value by 2
I suspect you are seeing incorrect colours because think you are in one mode
(5-5-5) when you should be dealing with another (5-6-5), and one of the
colour-channels is incorrect.
James
[snip]

This is what I did in the first place. I wrote a similar algorithm. The
difference is that I used multiplication and division to perform the
conversion from the 24bit color value to the 16bit color value. But
ofcourse shifting works faster. My code also determines the 16bit color
format. I verified this in debugging mode to be working correctly.
However the result is not the right color. In my opinion Windows uses a
different algorithm but the above to go from the 24bit value (that can
be used through the GDI functions) to the 16bit value used in high
color mode.

So I followed the good advice of [jongware]. Now I retrieve a GDI
device context for the surface that I want to draw to. Then I use
something as SetPixel(hdC, 0, 0, GetSysColor(COLOR_3DFACE)) to let GDI
fill the first pixel of the surface in the right color. Then I simply
read this value directly from display memory via DirectX, and use it to
replace necessary pixels. And this seems to work fine.

Regards,

Frederiek

[Jongware]
2006-02-24 15:02:24 UTC
Permalink
Post by Frederiek
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
[snip]
I am not using the GDI functions. My intent is not exactly to fill a
window client area with the COLOR_3DFACE color. I load a 32bit color
bitmap into memory. From there I copy the pixeldata to display memory.
But before the pixeldata is copied, I convert the 32bit data to 16bit
if the display mode is highcolor, i.e. 16bit. The bitmap also contains
3 RGB colors that I look for after the bitmap is loaded first in
memory. Another thing that I do before copying the pixels to the
backbuffer is to replace the pixeldata representing these colors with
the COLOR_3DFACE, COLOR_3DLIGHT and COLOR_3DSHADOW RGB colors. When in
32bit mode there's no problem since GetSysColor() returns the exact
24bit color values, i.e. the colors match exactly after conversion.
However, I when in 16bit mode I need to convert the result of
GetSysColor() to a 16bit value.
So I was wondering if there's a function or a standard method for
retrieving the exact 16 bit RGB system colors.
What I do currently is to determine the RGB bitmask used by the current
display mode. In 16bit mode this is mostly 5bit red, 6bit green and
5bit blue. Then I multiply for every color fraction the 8bit value from
the bitmap by the maximum target 16bit color fraction value, and divide
the result by the maximum 8bit value (i.e. 256).
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
I don't think that'll work any better. The more-or-less standard way of
converting color depths down is to right-shift out the unnecessary bits
(8-bit R >> 5-bit R, 8-bit G >> 6-bit G, 8-bit B >> 5-bit B).
RGB is 'mostly' 565 is, of course, not true. You might as well say that your
current color results are 'mostly' ok.
You'll have to determine what the color depth of the current screen is (in
16-bit color mode it might be 555 as well as 565; and with different RGB
orders as well).
Try this:
- do a GetSysColor for a couple of different items. Print out the RGB
values.
- Plot a single point in your 16-bit mode with each of these items.
- Read the pixel values and check the RGB bits.
That should, at least, give you an idea whether the colors *are* shifted
from one model to another. If you get inconsistent results you know at least
there is some background processing.
Post by Frederiek
I suppose there is no 16bit alternative to GetSysColor?
Nah. The old trick on windows 3.11 was to select a color, plot a pixel and
immediately read it back to check if it was plotted in the expected color,
or in some weird dithered or approximated mode.

[jongware]
Frederiek
2006-02-24 19:59:25 UTC
Permalink
Post by [Jongware]
Post by Frederiek
Post by Frederiek
Hello,
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors). I know there's a function GetSysColor() to
retrieve the system color for these items, but it returns RGB colors
for true color mode (24bit color). So every color component (R, G and
B) is represented by 8 bit. However these values cannot immediately be
used when in 16bit mode. Is there a way to retrieve the exact RGB value
in 16bit mode, i.e. a 16bit value instead of a 24bit value?
[snip]
I am not using the GDI functions. My intent is not exactly to fill a
window client area with the COLOR_3DFACE color. I load a 32bit color
bitmap into memory. From there I copy the pixeldata to display memory.
But before the pixeldata is copied, I convert the 32bit data to 16bit
if the display mode is highcolor, i.e. 16bit. The bitmap also contains
3 RGB colors that I look for after the bitmap is loaded first in
memory. Another thing that I do before copying the pixels to the
backbuffer is to replace the pixeldata representing these colors with
the COLOR_3DFACE, COLOR_3DLIGHT and COLOR_3DSHADOW RGB colors. When in
32bit mode there's no problem since GetSysColor() returns the exact
24bit color values, i.e. the colors match exactly after conversion.
However, I when in 16bit mode I need to convert the result of
GetSysColor() to a 16bit value.
So I was wondering if there's a function or a standard method for
retrieving the exact 16 bit RGB system colors.
What I do currently is to determine the RGB bitmask used by the current
display mode. In 16bit mode this is mostly 5bit red, 6bit green and
5bit blue. Then I multiply for every color fraction the 8bit value from
the bitmap by the maximum target 16bit color fraction value, and divide
the result by the maximum 8bit value (i.e. 256).
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
I don't think that'll work any better. The more-or-less standard way of
converting color depths down is to right-shift out the unnecessary bits
(8-bit R >> 5-bit R, 8-bit G >> 6-bit G, 8-bit B >> 5-bit B).
The result of shifting the bits left is probably the same as that of my
calculation with integers. But your suggestion is without doubt faster,
so if I stick with this method I can as well use the bitshifting
method. Not that speed really matters in my case, but it's the idea
that counts... :)
However, using float variables, would allow me to get a scientifically
more correct result. E.g. 26,5 I would round to 27, as where using
integer variables the result would be 26.
Post by [Jongware]
RGB is 'mostly' 565 is, of course, not true. You might as well say that your
current color results are 'mostly' ok.
I meant that 5.6.5 is the most common RGB format for 16 bit color
screens. Well, at least that is what I think. But ofcourse it would not
be nice to assume that the format is always is 5.6.5.
Post by [Jongware]
You'll have to determine what the color depth of the current screen is (in
16-bit color mode it might be 555 as well as 565; and with different RGB
orders as well).
- do a GetSysColor for a couple of different items. Print out the RGB
values.
- Plot a single point in your 16-bit mode with each of these items.
- Read the pixel values and check the RGB bits.
That should, at least, give you an idea whether the colors *are* shifted
from one model to another. If you get inconsistent results you know at least
there is some background processing.
[snip]
Post by [Jongware]
[jongware]
That's a good idea. I would not even have to care about the way colors
are shifted. I could just take the complete 16bit value and use it as
it is. But, I'm using DirectX, not GDI, so if wanted to use GDI if
would have to get a device context first, and that is a bit of a detour
because DirectX does not use device contexts by default. Perhaps I can
use this as a last resort.

Kind regards,

Frederiek
Lucian Wischik
2006-02-24 20:03:27 UTC
Permalink
Post by Frederiek
The result of shifting the bits left is probably the same as that of my
calculation with integers. But your suggestion is without doubt faster,
so if I stick with this method I can as well use the bitshifting
method. Not that speed really matters in my case, but it's the idea
that counts... :)
However, using float variables, would allow me to get a scientifically
more correct result. E.g. 26,5 I would round to 27, as where using
integer variables the result would be 26.
I thought your goal was to reproduce what the system does, not to get
scientifically more correct results ?

--
Lucian
Frederiek
2006-02-24 20:15:39 UTC
Permalink
Post by Lucian Wischik
Post by Frederiek
The result of shifting the bits left is probably the same as that of my
calculation with integers. But your suggestion is without doubt faster,
so if I stick with this method I can as well use the bitshifting
method. Not that speed really matters in my case, but it's the idea
that counts... :)
However, using float variables, would allow me to get a scientifically
more correct result. E.g. 26,5 I would round to 27, as where using
integer variables the result would be 26.
I thought your goal was to reproduce what the system does, not to get
scientifically more correct results ?
--
Lucian
:)) right. But perhaps Microsoft Windows programmers want to be
scientifically correct. One never knows...

Frederiek
Grzegorz Wróbel
2006-02-24 19:35:43 UTC
Permalink
Post by Frederiek
E.g.: red_16b = (red_32b * max_red_16b) / max_red_32b
Alas, the result is apparently not 100% accurate. I am currently using
integer values to do the calculation, but perhaps I should use floats
to get a closer match.
Assuming you got correct 16bit fomat(there are few possibiities like 5-6-5 or 5-5-5 etc) then perhaps the reason of inacuracy are rounding errors. How inacurate are the results?
try:

double red16d;
red16d = (1.0*red32b*max_red_16b)/max_red_32b;
red16d-floor(red16d)>=.5 ? red16b = ceil(red16d) : red16b = floor(red16b);
--
677265676F727940346E6575726F6E732E636F6D
Lucian Wischik
2006-02-23 18:34:38 UTC
Permalink
Post by Frederiek
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors)...
fill a window client area with the converted COLOR_3DFACE, it doesn't
exactly match the color of the surrounding window.
If that's your only goal, isnt' there a way to create a brush directly
from the standard-color-indices?
GetStockObject(COLOR_3DFACE+1)
or
FillRect(COLOR_3DFACE+1)
or something like that?

well, it's neither of the two ones I wrote, but it's something along
that line.

--
Lucian
James Brown [MVP]
2006-02-23 18:44:11 UTC
Permalink
Post by Lucian Wischik
Post by Frederiek
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors)...
fill a window client area with the converted COLOR_3DFACE, it doesn't
exactly match the color of the surrounding window.
If that's your only goal, isnt' there a way to create a brush directly
from the standard-color-indices?
GetStockObject(COLOR_3DFACE+1)
or
FillRect(COLOR_3DFACE+1)
or something like that?
well, it's neither of the two ones I wrote, but it's something along
that line.
--
Lucian
Yup, I reckon GetSysColorBrush(COLOR_3DFACE) would be the best bet.

(the +1 thing is for specifying a color-index for a background-brush when
registering a window-class, it's not required when using the GetSysColorxxx
APIs directly)

james
--
Microsoft MVP - Windows SDK
www.catch22.net
Free Win32 Source and Tutorials
[jongware]
2006-02-23 19:15:51 UTC
Permalink
Post by James Brown [MVP]
Post by Lucian Wischik
Post by Frederiek
I would like to retrieve some system colors, such as COLOR_3DFACE,
COLOR_3DLIGHT and COLOR_3DSHADOW when the display mode is set to
highcolor (16bit colors)...
fill a window client area with the converted COLOR_3DFACE, it doesn't
exactly match the color of the surrounding window.
If that's your only goal, isnt' there a way to create a brush directly
from the standard-color-indices?
GetStockObject(COLOR_3DFACE+1)
or
FillRect(COLOR_3DFACE+1)
or something like that?
well, it's neither of the two ones I wrote, but it's something along
that line.
--
Lucian
Yup, I reckon GetSysColorBrush(COLOR_3DFACE) would be the best bet.
(the +1 thing is for specifying a color-index for a background-brush when
registering a window-class, it's not required when using the
GetSysColorxxx
Post by James Brown [MVP]
APIs directly)
The added bonus is that if you receive a WM_SYSCOLORCHANGE you can re-draw
your own stuff to match the system colors:
The WM_SYSCOLORCHANGE message is sent to all top-level windows when a change
is made to a system color setting. (MSDN)
Great to show off!

[jongware]
Loading...