display non dithering colors for 256 color display 
Author Message
 display non dithering colors for 256 color display

Hi,

I'm writing an application that should be run on a
industrial PC that is capable of displaying 256 colors and
that has win 95. I want to be able to display different
light grey colors as backgrounds on forms and as
backcolors on grids (MSFlexgrid). The problem is that all
grey colors I try (except systemcolors like ButtonFace)
are displayed dithered.

I tried many things and here are two examples:

I have a bmp (imgPalette) that contains a palette with the
grey colors I want. I set the forms palette to that bmp
and I set the palettmode:

     Me.Palette = imgPalette.Picture
     Me.PaletteMode = vbPaletteModeCustom

Then I display the imgPalette on the form and I also
display a set of shapes for which I set the Fillcolor to
the colors contained in the imgPalette. The result is that
the imgPalette is displayed perfect but the same colors
displayed on the shapes are dithered. How can that be?
What am I doing wrong?

The other thing I tried is to display the systemcolors (in
order to find one that is not dithering).

    Dim arrPalette(256) As PALET{*filter*}TRY

    uDC = GetDC(fMainForm.hWnd)
    lngReturn = GetSystemPalet{*filter*}tries(uDC, 0, 256,
arrPalette(0))

    For i = 0 To 255
        Load Shape1(i + 1)

        Shape1(i).FillColor = RGB(arrPalette(i).peRed,
arrPalette(i).peGreen, arrPalette(i).peBlue)
        Shape1(i).Left = 300 * (i Mod 32) + 5
        Shape1(i).Top = 2100 + 300 * (i \ 32) + 5
        Shape1(i).Visible = True
    Next i

The systemcolors are displayed dithered (not all). What
should I do to be able to display a specific grey color,
non dithered, from VB?

/Lotta



Mon, 01 Nov 2004 17:36:36 GMT  
 display non dithering colors for 256 color display
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

On Thu, 16 May 2002 02:36:36 -0700, "Lotta"

Quote:

>Hi,

>I'm writing an application that should be run on a
>industrial PC that is capable of displaying 256 colors and
>that has win 95. I want to be able to display different
>light grey colors as backgrounds on forms and as
>backcolors on grids (MSFlexgrid). The problem is that all
>grey colors I try (except systemcolors like ButtonFace)
>are displayed dithered.

>I tried many things and here are two examples:

>I have a bmp (imgPalette) that contains a palette with the
>grey colors I want. I set the forms palette to that bmp
>and I set the palettmode:

>     Me.Palette = imgPalette.Picture
>     Me.PaletteMode = vbPaletteModeCustom

>Then I display the imgPalette on the form and I also
>display a set of shapes for which I set the Fillcolor to
>the colors contained in the imgPalette. The result is that
>the imgPalette is displayed perfect but the same colors
>displayed on the shapes are dithered. How can that be?
>What am I doing wrong?

>The other thing I tried is to display the systemcolors (in
>order to find one that is not dithering).

>    Dim arrPalette(256) As PALET{*filter*}TRY

>    uDC = GetDC(fMainForm.hWnd)
>    lngReturn = GetSystemPalet{*filter*}tries(uDC, 0, 256,
>arrPalette(0))

>    For i = 0 To 255
>        Load Shape1(i + 1)

>        Shape1(i).FillColor = RGB(arrPalette(i).peRed,
>arrPalette(i).peGreen, arrPalette(i).peBlue)
>        Shape1(i).Left = 300 * (i Mod 32) + 5
>        Shape1(i).Top = 2100 + 300 * (i \ 32) + 5
>        Shape1(i).Visible = True
>    Next i

>The systemcolors are displayed dithered (not all). What
>should I do to be able to display a specific grey color,
>non dithered, from VB?

>/Lotta



Mon, 01 Nov 2004 23:57:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. How do I display a specific grey color on a 256 color display without dithering?

2. 640*480 screen display with 256 color

3. 256 Color dithering

4. Colors display differently on 256 and 65K modes, as well as WIN '9

5. 256 color bitmap dithering

6. Using StretchBilt on 256-color display

7. How to display 16bit in 256 colors?

8. How to display 256 colors ImageList

9. How to display 256 colors ImageList

10. Cannot show dithered Bitmap in 256 color mode

11. Using 256 color Palettes in High/True Color

12. choose a color in a 256 color palette ?

 

 
Powered by phpBB® Forum Software