Help! VB's Palette at 256 Colors 
Author Message
 Help! VB's Palette at 256 Colors

In Visual Basic 6, when running in 256 colors, the choices I have available
for selecting the BackColor (etc) for a form or control are limited far
below the 256 colors the system palette actually supports. For example, I
want to set the back color of my forms to a shade of gray one step lighter
than the traditional battleship grey. I can successfully import bmp files
into image controls that have this shade of gray as part of the bitmap.
However, the corresponding shade of gray that shows in the VB palette
appears dithered. What gives? Is there a way around this? It appears the
Windows OS itself limits the system colors available for window backgrounds,
etc., below 256 colors when the display has been set to 256 colors, though
this does not apply to bitmaps and other graphics.

Thanks,
Curtis Marsden



Sun, 05 May 2002 03:00:00 GMT  
 Help! VB's Palette at 256 Colors

Quote:

>In Visual Basic 6, when running in 256 colors, the choices I have available
>for selecting the BackColor (etc) for a form or control are limited far
>below the 256 colors the system palette actually supports. For example, I

Those are just the colors you can pick by clicking the color bar: you can
enter any color you like in the property browser as a hex value &HBBGGRR
(blue, green, red components, each 00 to FF).

Quote:
>want to set the back color of my forms to a shade of gray one step lighter
>than the traditional battleship grey. I can successfully import bmp files
>into image controls that have this shade of gray as part of the bitmap.
>However, the corresponding shade of gray that shows in the VB palette
>appears dithered. What gives? Is there a way around this? It appears the
>Windows OS itself limits the system colors available for window
backgrounds,
>etc., below 256 colors when the display has been set to 256 colors, though
>this does not apply to bitmaps and other graphics.

By default, VB forms use a standard 256-color palette called the "halftone
palette".  If it doesn't contain your favorite color, it'll come out
dithered.  You _can_ make that color come out undithered, however.

There are several ways to do this.  The easiest is to make a 256-color
bitmap whose palette contains all the custom colors you need.  It can be
just 1x1 pixel (it's the palette that's important, not the displayed
colors).  Put a picturebox on your form and put it at the top of the ZOrder
(Tools\Format\Bring to Front, or PictureX.ZOrder in the Form_Load event).
Set the form's PaletteMode = UseZOrder.  Now you can draw undithered colors.

A second method uses the same bitmap, but you set the PaletteMode = Custom,
and the form's Palette property to the bitmap.  Now you can draw those
colors, but you need to use a bit of a trick.  You set an additional bit in
the color specification:

Form1.BackColor = RGB(r, g, b) Or &H2000000

You can also address the palette colors by palette index:

Form1.BackColor = 42 Or &H1000000

will color the form with the 42nd color in the palette.

Jim Deutch
MS Dev MVP



Sun, 05 May 2002 03:00:00 GMT  
 Help! VB's Palette at 256 Colors
I tried that and it doesn't work.  I had a black-to-blue 256 color palette that
I imported to the form, and the form still will not draw the full 256 shades of
blue.
Quote:


> >In Visual Basic 6, when running in 256 colors, the choices I have available
> >for selecting the BackColor (etc) for a form or control are limited far
> >below the 256 colors the system palette actually supports. For example, I

> Those are just the colors you can pick by clicking the color bar: you can
> enter any color you like in the property browser as a hex value &HBBGGRR
> (blue, green, red components, each 00 to FF).

> >want to set the back color of my forms to a shade of gray one step lighter
> >than the traditional battleship grey. I can successfully import bmp files
> >into image controls that have this shade of gray as part of the bitmap.
> >However, the corresponding shade of gray that shows in the VB palette
> >appears dithered. What gives? Is there a way around this? It appears the
> >Windows OS itself limits the system colors available for window
> backgrounds,
> >etc., below 256 colors when the display has been set to 256 colors, though
> >this does not apply to bitmaps and other graphics.

> By default, VB forms use a standard 256-color palette called the "halftone
> palette".  If it doesn't contain your favorite color, it'll come out
> dithered.  You _can_ make that color come out undithered, however.

> There are several ways to do this.  The easiest is to make a 256-color
> bitmap whose palette contains all the custom colors you need.  It can be
> just 1x1 pixel (it's the palette that's important, not the displayed
> colors).  Put a picturebox on your form and put it at the top of the ZOrder
> (Tools\Format\Bring to Front, or PictureX.ZOrder in the Form_Load event).
> Set the form's PaletteMode = UseZOrder.  Now you can draw undithered colors.

> A second method uses the same bitmap, but you set the PaletteMode = Custom,
> and the form's Palette property to the bitmap.  Now you can draw those
> colors, but you need to use a bit of a trick.  You set an additional bit in
> the color specification:

> Form1.BackColor = RGB(r, g, b) Or &H2000000

> You can also address the palette colors by palette index:

> Form1.BackColor = 42 Or &H1000000

> will color the form with the 42nd color in the palette.

> Jim Deutch
> MS Dev MVP



Sun, 12 May 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Change Screen Color Palette from 256 to hi-color in VB

2. Using 256 color Palettes in High/True Color

3. choose a color in a 256 color palette ?

4. Bitmap Color Palette editing-VB4 16 bit 256 color

5. Coloring a control from a 256-Color palette

6. Coloring a control from a 256-Color palette

7. color palette not accessible in 256+ color settings

8. Bitmap Color Palette editing-VB4 16 bit 256 color

9. 256 color palette with VB controls

10. Still need help with palette for 256 color mode

11. 256 Color Palette

12. halftone palette/256 colors

 

 
Powered by phpBB® Forum Software