MSVC Tutorial problem - Monochrome Palette

This is a discussion on MSVC Tutorial problem - Monochrome Palette within the C++ Programming forums, part of the General Programming Boards category; The exercise states: "Modify the CBmpPalette class used in the Dib example so that it is monochromatic, with only various ...

  1. #1
    Registered User
    Join Date
    Oct 2002
    Posts
    4

    Unhappy MSVC Tutorial problem - Monochrome Palette

    The exercise states:
    "Modify the CBmpPalette class used in the Dib example so that it is monochromatic, with only various shades of one color selected for the palette instead of colors from the bitmap."

    In my naiveté I had presume I simply set all of the RGB's to one - thus...
    From..
    Code:
        for( int ndx = 0; ndx < cPaletteEntries; ndx++ )
        {
            pPal->palPalEntry[ndx].peRed   = pColorTab[ndx].rgbRed;
            pPal->palPalEntry[ndx].peGreen = pColorTab[ndx].rgbGreen;
            pPal->palPalEntry[ndx].peBlue  = pColorTab[ndx].rgbBlue;
            pPal->palPalEntry[ndx].peFlags = NULL;
        }
    to....
    Code:
            pPal->palPalEntry[ndx].peRed   = pColorTab[ndx].rgbRed;
            pPal->palPalEntry[ndx].peGreen = pColorTab[ndx].rgbRed;
            pPal->palPalEntry[ndx].peBlue  = pColorTab[ndx].rgbRed;
            pPal->palPalEntry[ndx].peFlags = NULL;
    or maybe
    Code:
     
            pPal->palPalEntry[ndx].peRed   = pColorTab[ndx].rgbRed;
            pPal->palPalEntry[ndx].peGreen = 0;
            pPal->palPalEntry[ndx].peBlue  = 0;
            pPal->palPalEntry[ndx].peFlags = NULL;
    but this still ends up with a full 256-colour image.
    The text as you can see does not clarify how it could be done. Can anyone show where I may be going wrong?
    If you simply quote the class/procedure and whre I amy make changes it would help tremendrously.

    Many thanks,

    -Colkai

  2. #2
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    It looks like what you've tried should have worked, maybe try a different colour.

    Try Blue or Green instead of Red, I think red holds most of the information in an image so you may not see much of a diff in pic quality. You should see the same pic, only shaded the colour you have selected.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    417
    What compiler are you using? I want to look into 256 colors for Microsoft Visual C++ 6.0's dos consoles.... I don't think there is anything that simple.

  4. #4
    Registered User
    Join Date
    Oct 2002
    Posts
    4
    I am using the MSVC++ 4.0 developer studion standard.

    I obviously am new to this, but I would have thought setting just one colour would work. I just wonder if, for some reason, the wrong palette is being selected or overwritten. However, I have to assume the code in the tutorial is correct.
    I've looked through the sample programs but cannot find anything of help.
    FYI i'm running the software on a NT4.0 SP6a

  5. #5
    Registered User
    Join Date
    Oct 2002
    Posts
    4
    Actually, it gets more confusing, I just modified the section to this...
    Code:
    for( int ndx = 0; ndx < cPaletteEntries; ndx++ )
        {
         pPal->palPalEntry[ndx].peRed   = 12;
         pPal->palPalEntry[ndx].peGreen = 0;
         pPal->palPalEntry[ndx].peBlue  = 0;
         pPal->palPalEntry[ndx].peFlags = NULL;
        }
    and I still got a full 256-colour display of the image. I would have expected to get just a solid block of dark grey, (assuming of course that the palette items reflect the colour of the pixel).

    If anyone can clear this up I'd really be grateful.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem running a Cboard C++ tutorial!
    By Monkey Liar in forum C++ Programming
    Replies: 6
    Last Post: 02-15-2002, 02:32 AM
  2. MSVC and ATL problem
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 01-22-2002, 06:07 AM
  3. MSVC problem just started
    By Eber Kain in forum C++ Programming
    Replies: 2
    Last Post: 11-30-2001, 03:32 PM
  4. problem with output
    By Garfield in forum C Programming
    Replies: 2
    Last Post: 11-18-2001, 07:34 PM
  5. SDI Menu problem - Windows MSVC 6.0
    By Brown Drake in forum C++ Programming
    Replies: 0
    Last Post: 10-13-2001, 06:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21