CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Using palettes

  1. #1
    Guest

    Using palettes

    I am programming an application that needs a palette filled with shades of red.
    I have tried the following lines of code :

    For i = 0 To 255
    Pal.palPalEntry(i).peRed = i
    Pal.palPalEntry(i).peGreen = 0
    Pal.palPalEntry(i).peBlue = 0
    Pal.palPalEntry(i).peFlags = 0
    Next i
    hPal = CreatePalette(Pal)
    hHoldPrevPal = SelectPalette(Form1.hdc, hPal, True)
    RealizePalette (Form1.hdc)

    RealizePalette has returned a value of 249.
    While trying all shades of red, from RGB(0,0,0) to RGB(255,0,0) , I could get only 4 distinct shades of red,
    with all the others dithered.

    Thanks for any help,
    Gino.


  2. #2
    Join Date
    Oct 1999
    Location
    WA
    Posts
    2,393

    Re: Using palettes

    That is correct.

    You should use SelectPalette(Form1.hdc, hPal, False) to set the palette as foreground palette. Only foreground palette can force other colors out of system palette.

    With foreground palette, you may get 236+3 levels of red shade.

    A C/C++ programmer


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured