Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

256 color vs. 16 bit (HiColor)

1 view
Skip to first unread message

Paul Applegate

unread,
May 20, 1997, 3:00:00 AM5/20/97
to

I am having problems displaying all the colors I would like to display in
my application. The first topic of confusion for me is what I'm dealing
with when I am using 16 bit HiColor mode on my graphics adapter. I used
GetDeviceCaps to query the various parameters such as COLORRES,
SIZEPALETTE, NUMCOLORS, etc. The only one that made sense was the
BITSPIXEL of 16. All the other values were 0 or -1. When I switched to
256 color mode, I got all the values I expected. Also, I found an article
in this newsgroup that discussed how to 'realize' the palette by responding
to WM_QUERYNEWPALETTE and WM_PALETTECHANGED. I put the code in but never
received either of those messages in 16-bit mode. When I switched to 256
color mode, I started receiving them. Is there no palette in 16-bit mode?

I have a main Login screen that I put up that has a TImage bitmap with over
200 colors in it. Once I log in, I go to a new screen that displays
various panels. I can't seem to get the panels to be the color I want.
They look real close to the color I picked, but when examined closely by
capturing the image and zooming on it in paint brush it is obvious it is
dithered. This causes a problem when I try to do floodfills on portions of
the screen. If I can't respond to the windows messages to change palettes,
how do I get more (solid) colors onto the screen in 16-bit mode?
Any help would be appreciated. Thank You.

Paul Applegate
app...@webxs.com

Carsten Gehling

unread,
May 20, 1997, 3:00:00 AM5/20/97
to

Well, first of all: No there is no palette in 16-bit mode.

16-bit mode is a bit <g> like true color (24-bit mode) as every pixel has
its own RGB value instead of an index into a palette.
The problem is, however, that 16-bit mode only assigns 5 bits to each of
the 3 values. 24-bit assigns 8 bits to each - and so does 8-bit
(256-colors) in a way.
In 8-bit, although you can only show 256 different colors on screen at a
time, you can select them from 2^24 colors. In 16-bit you can only show AND
choose between 2^16 different colors. So even though you can show more
colors there are some, that you simply cannot display.

This is where your dithering problem come into the picture. If you try to
display a color that is not a "true" 16-bit color, it will map into some
dithered approximation. The solution is to use colors that are true to
16-bit.

16-bit mode distributes all 5 bits of each RGB value to fit as large a
range as possible.

$0 $0 $0 is black
$1F $1F $1F (= all 5 bits in each value set) is white
$1F $0 $0 is pure red

and so on. If you have any RGB-values above $1F, it will be assumed a
24-bit mode value and converted into a 16-bit mode value.

Hopes this helps.

- Carsten


Paul Applegate <app...@webxs.com> skrev i artiklen
<01bc64d7$6f8d2ac0$17fda2cd@applegate>...

Ray Lischner

unread,
May 20, 1997, 3:00:00 AM5/20/97
to

On 20 May 1997 04:41:52 GMT, "Paul Applegate" <app...@webxs.com>
wrote:

> Is there no palette in 16-bit mode?

Correct. Windows uses palettes only in 256-color mode.

--
Ray Lischner
Author of Secrets of Delphi 2 (http://www.tempest-sw.com/secrets/)

Paul Applegate

unread,
May 20, 1997, 3:00:00 AM5/20/97
to

Thank you for the answer Carsten, you solved my problem. Just for anyone
else's benefit, I found that for 16-bit colors each color element (R, G, &
B) must be a value with 0 in the least significant three bits. For
example, $0088F030, $00C84860, and $00A04850 are all solid colors.

Paul Applegate
app...@webxs.com

Andy McFarland

unread,
May 21, 1997, 3:00:00 AM5/21/97
to

> > I have a main Login screen that I put up that has a TImage bitmap with
> over
> > 200 colors in it. Once I log in, I go to a new screen that displays
> > various panels. I can't seem to get the panels to be the color I want.

> > They look real close to the color I picked, but when examined closely
by
> > capturing the image and zooming on it in paint brush it is obvious it
is
> > dithered. This causes a problem when I try to do floodfills on
portions
> of
> > the screen. If I can't respond to the windows messages to change
> palettes,
> > how do I get more (solid) colors onto the screen in 16-bit mode?
> > Any help would be appreciated. Thank You.

I use the API GetNearestColor to avoid dithered RGB values.

Andy

Evandro Menezes

unread,
May 22, 1997, 3:00:00 AM5/22/97
to

"Carsten Gehling" <alv...@inet.uni-c.dk> wrote:

>16-bit mode is a bit <g> like true color (24-bit mode) as every pixel has
>its own RGB value instead of an index into a palette.
>The problem is, however, that 16-bit mode only assigns 5 bits to each of
>the 3 values. 24-bit assigns 8 bits to each - and so does 8-bit
>(256-colors) in a way.

Therefore, it's actually 15-bit mode. But I can quite remember that some
video drivers for Win16 offered the choice of both 15 and 16-bit modes. How
was this 16-bit mode then? Would it be something with NTSC-like weighting,
such as 6 bits for R, 8 bits for G and 2 for B?

>In 8-bit, although you can only show 256 different colors on screen at a
>time, you can select them from 2^24 colors. In 16-bit you can only show AND
>choose between 2^16 different colors. So even though you can show more
>colors there are some, that you simply cannot display.

Again, the choice would be among 2^15 colors.

Could anyone shed a light on this?

TIA

__________________________________________________________________
Evandro Menezes Sao Paulo, SP Brazil
TMTI/ENG/STM0 BOSCH Telecom
tel: +55 (11) 541-9555 #166 fax: +55 (11) 246-0016
evandro...@pcm.bosch.de www.geocities.com/SiliconValley/7263

Dave Sherohman

unread,
May 22, 1997, 3:00:00 AM5/22/97
to

"Paul Applegate" <app...@webxs.com> wrote:
>I am having problems displaying all the colors I would like to display in
>my application. The first topic of confusion for me is what I'm dealing
>with when I am using 16 bit HiColor mode on my graphics adapter. I used
>GetDeviceCaps to query the various parameters such as COLORRES,
>SIZEPALETTE, NUMCOLORS, etc. The only one that made sense was the
>BITSPIXEL of 16. All the other values were 0 or -1. When I switched to
>256 color mode, I got all the values I expected. Also, I found an article
>in this newsgroup that discussed how to 'realize' the palette by responding
>to WM_QUERYNEWPALETTE and WM_PALETTECHANGED. I put the code in but never
>received either of those messages in 16-bit mode. When I switched to 256
>color mode, I started receiving them. Is there no palette in 16-bit mode?

There is no palette in any (normal) graphics mode which can display
more than 256 colors at a time. The various functions regarding
palette information return -1 because there isn't a palette to report
on. Likewise, the palette is never changed because it doesn't exist.

Create and save the image in 16- or 24-bit color. If you load up a
dithered 256-color image, you'll have a dithered image with no more
than 256 colors in it regardless of the mode in which the image is
displayed.

Derek A Benner

unread,
May 22, 1997, 3:00:00 AM5/22/97
to

Evandro Menezes wrote:
>
> Therefore, it's actually 15-bit mode. But I can quite remember that some
> video drivers for Win16 offered the choice of both 15 and 16-bit modes. How
> was this 16-bit mode then? Would it be something with NTSC-like weighting,
> such as 6 bits for R, 8 bits for G and 2 for B?
>
> Again, the choice would be among 2^15 colors.
>
> Could anyone shed a light on this?
>
> TIA

Evandro,

The proper weighing of a 16-bit vs. 15-bit color value is that the
15-bit value is actually three 5-bit values for each Red, Green and Blue
with the highest bit set to 0 while in the 16-bit version the highest
bit can represent a transparency value or the 16 bits of value may be
redistributed as 5 bits of Red, 6 bits of Green and 5 bits of Blue

15-bit

MS Bit LS Bit
0 RRRRR GGGGG BBBBB

16-bit (Targa16)

MS Bit LS Bit
T RRRRR GGGGG BBBBB

16-bit (Other type)

MS Bit LS Bit
RRRRR GGGGGG BBBBB

Hope this makes it more clear.

Derek

Tim Roberts

unread,
May 23, 1997, 3:00:00 AM5/23/97
to

evandro...@pcm.bosch.de (Evandro Menezes) wrote:

>Therefore, it's actually 15-bit mode. But I can quite remember that some
>video drivers for Win16 offered the choice of both 15 and 16-bit modes. How
>was this 16-bit mode then? Would it be something with NTSC-like weighting,
>such as 6 bits for R, 8 bits for G and 2 for B?

16-bit color in Windows is virtually always 5:6:5, although a few video
adapters also offer 6:5:5 and 6:6:4 modes.

NTSC doesn't really penalize blue as much as you describe. It's hard to
compare directly because the components are so different, but overall it's
closer to 5:7:4.

>>In 8-bit, although you can only show 256 different colors on screen at a
>>time, you can select them from 2^24 colors. In 16-bit you can only show AND
>>choose between 2^16 different colors. So even though you can show more
>>colors there are some, that you simply cannot display.
>

>Again, the choice would be among 2^15 colors.
>Could anyone shed a light on this?

I'd be happy to help, but I'm afraid I didn't see a question in the second
part. What is it you wanted illuminated? :)


-- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

0 new messages