setting pixels to palette index

This is a discussion on setting pixels to palette index within the Windows Programming forums, part of the Platform Specific Boards category; I am writing a palette editor and will be displaying the palette as a long bar, shaded from one end ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    322

    setting pixels to palette index

    I am writing a palette editor and will be displaying the palette as a long bar,
    shaded from one end to the other with each palette color.

    I need to update the palette display as the palette entries are changed, and
    also update the image that the palette is used for.

    Palette animation seems the best way to do this.

    My question though, is how do I draw with palette index values instead of
    color values?

    For example, SetPixel(, , , ) passes a color reference value, not a palette index.

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,602
    Quote Originally Posted by megafiddle View Post
    For example, SetPixel(, , , ) passes a color reference value, not a palette index.
    Hmm, and want does a palette hold? ( Tricky question )
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    322
    Well, yes the palette also holds color reference values, but a pixel value could be
    a color value (an RGB value) or an index into a color table (the palette).

    So the pixel values might never change, but the color values they "point to" can change.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,602
    I agree, but I still don't understand your problem...
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    322
    How do you you specify a particular palette index for a pixel?
    Rather than an RGB value?

    For example, my palette color bar needs to have the pixels range from an index
    value of zero at one end to "some-max-value" at the other end.

  6. #6
    Registered User
    Join Date
    Mar 2011
    Posts
    322
    I should elaborate.

    I am working on a program to generate and color Mandelbrot and Julia set images.
    The images consist of "escape time" maps, with each x,y point having a time value
    and each point represented by a pixel on the screen. The time values are fixed for
    any particular image.
    Typically each time value is used to look up a color in a table and then that point
    is plotted in that color. The problem is that it is tedious and time consuming to make
    changes to the color table and then replot all of the pixels each time.

    So I don't want to set my first pixel to "blue", for example. I want to set it to a
    palette index number. The index number would be equal to the "time" value for that
    point. (all similar time values will have similar colors assigned)
    Then, when I want to change the color for all points with that particular time value,
    I only need to change the palette entry with that index number.
    The same would be true for the palette color bar, which I use for editing it. The pixels
    along the bar needs to be colored along it's length just as the colors exist in the palette.
    The pixels at the left end of the bar would be set to palette entry zero. Moving right
    along the bar, the pixels would be set to progressively higher palette index values.

    The whole purpose is to provide immediate update of the image and color bar just
    by animating the palette. No need to redraw everything in the new colors.

    So to rephrase the question, how do I set a pixel to a particular palette entry index
    value, instead of setting it to "blue"?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. short index vs. int index
    By ardavirus in forum C Programming
    Replies: 3
    Last Post: 06-13-2011, 05:09 AM
  2. ? about this> index::index () : type_intex()
    By bobk544 in forum C++ Programming
    Replies: 5
    Last Post: 09-30-2005, 02:59 PM
  3. Palette in DirectX
    By SuperNewbie in forum Windows Programming
    Replies: 0
    Last Post: 04-06-2002, 03:46 AM
  4. Need help making a palette.....
    By Zoalord in forum Windows Programming
    Replies: 0
    Last Post: 03-28-2002, 03:37 PM
  5. Setting the palette on a BITMAPINFO struct
    By SMurf in forum Windows Programming
    Replies: 6
    Last Post: 09-14-2001, 06:00 PM

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