Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>_remappalette() assign colors to selected pixel values</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 _remappalette()         Assign colors to selected pixel values

 #include   <graph.h>

 long far _remappalette( pixel, color );
  short pixel;      Pixel value to reassign
  long color;       New color number for pixel

    _remappalette() assigns one pixel value to a specified color number
    that is available on the display hardware and selected mode. In
    graphics mode, a pixel can be represented as a one-, two-, or four-
    bit value depending on the mode selected. There is also a separate
    ordinal color representation, where each color that can be displayed
    by a particular video mode is represented by a unique ordinal value.
    The mapping of pixel values to display colors creates a "palette" of
    colors that can be displayed.

    When a palette is remapped, all images, including those already
    displayed, immediately show the new palette.

       Returns:     If successful, _remappalette() returns a the previous
                    color number or pixel value. If unsuccessful it
                    returns 0.

         Notes:     _remappalette() requires an EGA, MCGA, or VGA display
                    system.

                    The default array of color numbers, with no
                    remapping, is as follows:

                    No.   Color                No.   Color
                    ---   ---------------      ---   ---------------
                     0    Black                 8    Dark gray
                     1    Blue                  9    Light blue
                     2    Green                10    Light green
                     3    Cyan                 11    Light cyan
                     4    Red                  12    Light red
                     5    Magenta              13    Light magenta
                     6    Brown                14    Yellow
                     7    White                15    Bright white

                    The actual number of colors mapped depends on the
                    number of colors supported by the active video mode.

                    The MCGA and VGA color graphics modes support a
                    palette of 256k colors, using separate blue, green
                    and red bytes. Since colors are split between bytes,
                    the color numbers are not continuous. To provide
                    compatibility with EGA conventions the following
                    manifest constants, defined in graph.h, are available
                    to represent the default color numbers:

                    No.   Color                 No.   Color
                    ---   ---------------       ---   ---------------
                     0    _BLACK                 8    _GRAY
                     1    _BLUE                  9    _LIGHTBLUE
                     2    _GREEN                10    _LIGHTGREEN
                     3    _CYAN                 11    _LIGHTCYAN
                     4    _RED                  12    _LIGHTRED
                     5    _MAGENTA              13    _LIGHTMAGENTA
                     6    _BROWN                14    _LIGHTYELLOW
                     7    _WHITE                15    _BRIGHTWHITE

   Portability:     MS-DOS only, true MDPA, CGA, EGA, MCGA, or VGA video
                    compatibles

 -------------------------------- Example ---------------------------------

    This program remaps pixel attribute 3 to color light red.

           #include <graph.h>

           main()
           {
              . . . select video mode . . .

              _remappalette( 3, _LIGHTRED );

              . . . display images . . .

           }


See Also: _remapallpalette() _selectpalette() _setvideomode()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson