From 6deb7c67498f0022e6bd99ef754bc0d57c308c4f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Tue, 14 Jun 2005 07:29:16 +0000 Subject: [PATCH] Documented the public methods, changed the file description git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13111 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/SystemPalette.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/servers/app/SystemPalette.cpp b/src/servers/app/SystemPalette.cpp index 56a3f39ac3..366e34b21d 100644 --- a/src/servers/app/SystemPalette.cpp +++ b/src/servers/app/SystemPalette.cpp @@ -22,8 +22,7 @@ // File Name: SystemPalette.cpp // Authors: DarkWyrm // Stefano Ceccherini -// Description: One global function to generate the palette which is -// the default BeOS System palette and the variable to go with it +// Description: Methods to initialize and get the system color_map. // //------------------------------------------------------------------------------ #include @@ -147,10 +146,9 @@ color_distance(uint8 red1, uint8 green1, uint8 blue1, int bd = (int)blue1 - (int)blue2; // distance according to psycho-visual tests + // algorithm taken from here: + // http://www.stud.uni-hannover.de/~michaelt/juggle/Algorithms.pdf int rmean = ((int)red1 + (int)red2) / 2; - /*return (2 + rmean / 256) * rd * rd - + 4 * gd * gd - + (2 + (255 - rmean) / 256) * bd * bd;*/ return (((512 + rmean) * rd * rd) >> 8) + 4 * gd * gd + (((767 - rmean) * bd * bd) >> 8); @@ -160,10 +158,6 @@ color_distance(uint8 red1, uint8 green1, uint8 blue1, static uint8 FindClosestColor(const rgb_color &color, const rgb_color *palette) { - // TODO: This isn't working 100% correctly. - // At least, it doesn't map colors as beos does. - // Could be a bug/different behaviour in color_distance - uint8 closestIndex = 0; unsigned closestDistance = UINT_MAX; for (int32 i = 0; i < 256; i++) { @@ -222,6 +216,8 @@ FillColorMap(const rgb_color *palette, color_map *map) } +/*! \brief Initializes the system color_map. +*/ void InitializeColorMap() { @@ -229,6 +225,9 @@ InitializeColorMap() } +/*! \brief Returns a pointer to the system palette. + \return A pointer to the system palette. +*/ const rgb_color * SystemPalette() { @@ -236,6 +235,9 @@ SystemPalette() } +/*! \brief Returns a pointer to the system color_map structure. + \return A pointer to the system color_map. +*/ const color_map * SystemColorMap() {