Results 1 to 5 of 5

Thread: Colors

  1. #1

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Talking Colors

    How do i work with colors? I read on the MSDN that you can have a RGB macro or COLORREF, but it does not work. Can anyone please give me an example of how to make them work? Thanks
    Amon Ra
    The Power of Learning.

  2. #2
    ChimpFace9000
    Guest
    COLOREF is a type of variable. It holds a color.

    Code:
    COLORREF ColorRef;
    ColorRef = RGB(RedValue, GreenValue, BlueValue);
    Then if you want to get the red green and blue values out of ColorRef, use GetRValue, GetGValue, GetBValue.

    Does that answer your question? If not, let me know.

  3. #3
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    As a matter of course, whenever you encounter a new type, always look it up in the header files for the exact definition. COLORREF is actually an unsigned long (surprised?) and if you look at RGB you can just see how it's packing the 3 bytes into a 4-byte long

    I don't have any practical information, but it's a useful tidbit
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  4. #4

    Thread Starter
    Hyperactive Member Amon Ra's Avatar
    Join Date
    Feb 2001
    Location
    In some cave on Uranus...
    Posts
    500

    Question ...

    Thanks for the tip Pars', but thinking about it, I am not so sure about how the x-bit work. How the memory is allocated differently for them... Could you(or someone else) explain to me ? Thanks a lot
    Amon Ra
    The Power of Learning.

  5. #5
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Ok. RGB is a macro, so it's expanded at preprocess time (during compilation). If you look at it it's just doing shifting and OR-ing on the individual bytes, so that the 3 bytes you want are stored within the 4-byte long value, and can be moved around as one, with no worries
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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