2006-02-06 14:47:13 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2006, Haiku.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm <bpmagic@columbus.rr.com>
|
|
|
|
*/
|
|
|
|
|
2002-12-31 21:21:14 +03:00
|
|
|
|
|
|
|
#include "RGBColor.h"
|
2003-01-01 01:19:48 +03:00
|
|
|
#include "SystemPalette.h"
|
2006-02-06 14:47:13 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2006-05-19 19:52:21 +04:00
|
|
|
#include <stdlib.h>
|
2006-02-06 14:47:13 +03:00
|
|
|
|
|
|
|
|
2006-03-15 03:22:01 +03:00
|
|
|
/*!
|
|
|
|
\brief An approximation of 31/255, which is needed for converting from 32-bit
|
|
|
|
colors to 16-bit and 15-bit.
|
|
|
|
*/
|
|
|
|
#define RATIO_8_TO_5_BIT .121568627451
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief An approximation of 63/255, which is needed for converting from 32-bit
|
|
|
|
colors to 16-bit.
|
|
|
|
*/
|
|
|
|
#define RATIO_8_TO_6_BIT .247058823529
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief An approximation of 255/31, which is needed for converting from 16-bit
|
|
|
|
and 15-bit colors to 32-bit.
|
|
|
|
*/
|
|
|
|
#define RATIO_5_TO_8_BIT 8.22580645161
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief An approximation of 255/63, which is needed for converting from 16-bit
|
|
|
|
colors to 32-bit.
|
|
|
|
*/
|
|
|
|
#define RATIO_6_TO_8_BIT 4.04761904762
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/*!
|
|
|
|
\brief Function for easy conversion of 16-bit colors to 32-bit
|
|
|
|
\param col Pointer to an rgb_color.
|
|
|
|
\param color RGB16 color
|
|
|
|
|
|
|
|
This function will do nothing if passed a NULL 32-bit color.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetRGBColor16(rgb_color *col,uint16 color)
|
|
|
|
{
|
|
|
|
if(!col)
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint16 r16,g16,b16;
|
|
|
|
|
|
|
|
// alpha's the easy part
|
|
|
|
col->alpha=0;
|
|
|
|
|
|
|
|
r16= (color >> 11) & 31;
|
|
|
|
g16= (color >> 5) & 63;
|
|
|
|
b16= color & 31;
|
|
|
|
|
|
|
|
col->red=uint8(r16 * RATIO_5_TO_8_BIT);
|
|
|
|
col->green=uint8(g16 * RATIO_6_TO_8_BIT);
|
|
|
|
col->blue=uint8(b16 * RATIO_5_TO_8_BIT);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Finds the index of the closest matching color in a rgb_color palette array
|
|
|
|
\param palette Array of 256 rgb_color objects
|
|
|
|
\param color Color to match
|
|
|
|
\return Index of the closest matching color
|
|
|
|
|
|
|
|
Note that passing a NULL palette will always return 0 and passing an array of less
|
|
|
|
than 256 rgb_colors will cause a crash.
|
|
|
|
*/
|
|
|
|
static uint8
|
|
|
|
FindClosestColor(const rgb_color *palette, rgb_color color)
|
|
|
|
{
|
|
|
|
if (!palette)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
uint16 cindex = 0, cdelta = 765, delta = 765;
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < 256; i++) {
|
|
|
|
const rgb_color *c = &(palette[i]);
|
|
|
|
delta = abs(c->red-color.red) + abs(c->green-color.green)
|
|
|
|
+ abs(c->blue-color.blue);
|
|
|
|
|
|
|
|
if (delta == 0) {
|
|
|
|
cindex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (delta < cdelta) {
|
|
|
|
cindex = i;
|
|
|
|
cdelta = delta;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (uint8)cindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Constructs a RGBA15 color which best matches a given 32-bit color
|
|
|
|
\param color Color to match
|
|
|
|
\return The closest matching color's value
|
|
|
|
|
|
|
|
Format is ARGB, 1:5:5:5
|
|
|
|
*/
|
|
|
|
static uint16
|
|
|
|
FindClosestColor15(rgb_color color)
|
|
|
|
{
|
|
|
|
uint16 r16 = uint16(color.red * RATIO_8_TO_5_BIT);
|
|
|
|
uint16 g16 = uint16(color.green * RATIO_8_TO_5_BIT);
|
|
|
|
uint16 b16 = uint16(color.blue * RATIO_8_TO_5_BIT);
|
|
|
|
|
|
|
|
// start with alpha value
|
|
|
|
uint16 color16 = color.alpha > 127 ? 0x8000 : 0;
|
|
|
|
|
|
|
|
color16 |= r16 << 10;
|
|
|
|
color16 |= g16 << 5;
|
|
|
|
color16 |= b16;
|
|
|
|
|
|
|
|
return color16;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
\brief Constructs a RGB16 color which best matches a given 32-bit color
|
|
|
|
\param color Color to match
|
|
|
|
\return The closest matching color's value
|
|
|
|
|
|
|
|
Format is RGB, 5:6:5
|
|
|
|
*/
|
|
|
|
static uint16
|
|
|
|
FindClosestColor16(rgb_color color)
|
|
|
|
{
|
|
|
|
uint16 r16 = uint16(color.red * RATIO_8_TO_5_BIT);
|
|
|
|
uint16 g16 = uint16(color.green * RATIO_8_TO_6_BIT);
|
|
|
|
uint16 b16 = uint16(color.blue * RATIO_8_TO_5_BIT);
|
|
|
|
|
|
|
|
uint16 color16 = r16 << 11;
|
|
|
|
color16 |= g16 << 5;
|
|
|
|
color16 |= b16;
|
|
|
|
|
|
|
|
return color16;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #pragma mark -
|
|
|
|
|
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor from specified values
|
2003-01-20 02:04:58 +03:00
|
|
|
\param red red
|
|
|
|
\param green green
|
|
|
|
\param blue blue
|
|
|
|
\param alpha alpha, defaults to 255
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2003-01-18 23:12:03 +03:00
|
|
|
RGBColor::RGBColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
|
|
|
SetColor(r,g,b,a);
|
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor from specified values
|
2003-01-20 02:04:58 +03:00
|
|
|
\param red red
|
|
|
|
\param green green
|
|
|
|
\param blue blue
|
|
|
|
\param alpha alpha, defaults to 255
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2003-06-23 06:54:52 +04:00
|
|
|
RGBColor::RGBColor(int r, int g, int b, int a)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
SetColor(r, g, b, a);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor from an rgb_color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to initialize from
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::RGBColor(const rgb_color &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
SetColor(color);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-03-15 03:22:01 +03:00
|
|
|
#if 0
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor from a 16-bit RGBA color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to initialize from
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::RGBColor(uint16 color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
SetColor(color);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
2006-03-15 03:22:01 +03:00
|
|
|
#endif
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor from an index color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to initialize from
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::RGBColor(uint8 color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
SetColor(color);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Copy Contructor
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to initialize from
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::RGBColor(const RGBColor &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32 = color.fColor32;
|
|
|
|
fColor16 = color.fColor16;
|
|
|
|
fColor8 = color.fColor8;
|
|
|
|
fUpdate8 = color.fUpdate8;
|
|
|
|
fUpdate16 = color.fUpdate16;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Create an RGBColor with the values(0,0,0,0)
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-05-05 03:48:19 +04:00
|
|
|
RGBColor::RGBColor()
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
SetColor(0, 0, 0, 0);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Returns the color as the closest 8-bit color in the palette
|
2003-01-01 01:19:48 +03:00
|
|
|
\return The palette index for the current color
|
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
uint8
|
|
|
|
RGBColor::GetColor8() const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
if (fUpdate8) {
|
|
|
|
fColor8 = FindClosestColor(SystemPalette(), fColor32);
|
|
|
|
fUpdate8 = false;
|
2003-10-04 23:57:54 +04:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
return fColor8;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-11-03 04:51:50 +03:00
|
|
|
/*!
|
|
|
|
\brief Returns the color as the closest 15-bit color
|
|
|
|
\return 15-bit value of the current color plus 1-bit alpha
|
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
uint16
|
|
|
|
RGBColor::GetColor15() const
|
2003-11-03 04:51:50 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
if (fUpdate15) {
|
|
|
|
fColor15 = FindClosestColor15(fColor32);
|
|
|
|
fUpdate15 = false;
|
2003-11-03 04:51:50 +03:00
|
|
|
}
|
2006-02-06 14:47:13 +03:00
|
|
|
|
|
|
|
return fColor15;
|
2003-11-03 04:51:50 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Returns the color as the closest 16-bit color
|
2003-11-03 04:51:50 +03:00
|
|
|
\return 16-bit value of the current color
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
uint16
|
|
|
|
RGBColor::GetColor16() const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
if (fUpdate16) {
|
|
|
|
fColor16 = FindClosestColor16(fColor32);
|
|
|
|
fUpdate16 = false;
|
2003-10-04 23:57:54 +04:00
|
|
|
}
|
2006-02-06 14:47:13 +03:00
|
|
|
|
|
|
|
return fColor16;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Returns the color as a 32-bit color
|
|
|
|
\return current color, including alpha
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
rgb_color
|
|
|
|
RGBColor::GetColor32() const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
return fColor32;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified values
|
2003-01-20 02:04:58 +03:00
|
|
|
\param red red
|
|
|
|
\param green green
|
|
|
|
\param blue blue
|
|
|
|
\param alpha alpha, defaults to 255
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::SetColor(uint8 r, uint8 g, uint8 b, uint8 a)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32.red = r;
|
|
|
|
fColor32.green = g;
|
|
|
|
fColor32.blue = b;
|
|
|
|
fColor32.alpha = a;
|
|
|
|
|
|
|
|
fUpdate8 = fUpdate16 = true;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified values
|
2003-01-20 02:04:58 +03:00
|
|
|
\param red red
|
|
|
|
\param green green
|
|
|
|
\param blue blue
|
|
|
|
\param alpha alpha, defaults to 255
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::SetColor(int r, int g, int b, int a)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32.red = (uint8)r;
|
|
|
|
fColor32.green = (uint8)g;
|
|
|
|
fColor32.blue = (uint8)b;
|
|
|
|
fColor32.alpha = (uint8)a;
|
2003-10-04 23:57:54 +04:00
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
fUpdate8 = fUpdate16 = true;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-03-15 03:22:01 +03:00
|
|
|
#if 0
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified value
|
2003-01-20 02:04:58 +03:00
|
|
|
\param col16 color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::SetColor(uint16 col16)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor16 = col16;
|
|
|
|
SetRGBColor(&fColor32,col16);
|
2003-10-04 23:57:54 +04:00
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
fUpdate8 = true;
|
|
|
|
fUpdate16 = false;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
2006-03-15 03:22:01 +03:00
|
|
|
#endif
|
2002-12-31 21:21:14 +03:00
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified index in the palette
|
2003-01-20 02:04:58 +03:00
|
|
|
\param col8 color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::SetColor(uint8 col8)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor8 = col8;
|
|
|
|
fColor32 = SystemPalette()[col8];
|
2003-10-04 23:57:54 +04:00
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
fUpdate8 = false;
|
|
|
|
fUpdate16 = true;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified color
|
2003-01-20 02:04:58 +03:00
|
|
|
\param color color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::SetColor(const rgb_color &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32 = color;
|
|
|
|
fUpdate8 = fUpdate16 = true;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-12-20 00:14:16 +03:00
|
|
|
void
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::SetColor(const RGBColor &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32 = color.fColor32;
|
|
|
|
fColor16 = color.fColor16;
|
|
|
|
fColor8 = color.fColor8;
|
|
|
|
fUpdate8 = color.fUpdate8;
|
|
|
|
fUpdate16 = color.fUpdate16;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-12-20 00:14:16 +03:00
|
|
|
const RGBColor&
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::operator=(const RGBColor &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32 = color.fColor32;
|
|
|
|
fColor16 = color.fColor16;
|
|
|
|
fColor8 = color.fColor8;
|
|
|
|
fUpdate8 = color.fUpdate8;
|
|
|
|
fUpdate16 = color.fUpdate16;
|
2005-12-20 00:14:16 +03:00
|
|
|
|
2002-12-31 21:21:14 +03:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Set the object to specified color
|
2006-02-06 14:47:13 +03:00
|
|
|
\param color color to copy
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2005-12-20 00:14:16 +03:00
|
|
|
const RGBColor&
|
2006-02-06 14:47:13 +03:00
|
|
|
RGBColor::operator=(const rgb_color &color)
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
fColor32 = color;
|
|
|
|
fUpdate8 = fUpdate16 = true;
|
2002-12-31 21:21:14 +03:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Prints the 32-bit values of the color to standard out
|
2003-01-01 01:19:48 +03:00
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
void
|
|
|
|
RGBColor::PrintToStream(void) const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
printf("RGBColor(%u,%u,%u,%u)\n",
|
|
|
|
fColor32.red, fColor32.green, fColor32.blue, fColor32.alpha);
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Overloaded comaparison
|
2003-01-01 01:19:48 +03:00
|
|
|
\return true if all color elements are exactly equal
|
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
bool
|
|
|
|
RGBColor::operator==(const rgb_color &color) const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
return fColor32.red == color.red
|
|
|
|
&& fColor32.green == color.green
|
|
|
|
&& fColor32.blue == color.blue
|
|
|
|
&& fColor32.alpha == color.alpha;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2003-01-01 01:19:48 +03:00
|
|
|
/*!
|
2003-01-18 23:12:03 +03:00
|
|
|
\brief Overloaded comaparison
|
2003-01-01 01:19:48 +03:00
|
|
|
\return true if all color elements are exactly equal
|
|
|
|
*/
|
2006-02-06 14:47:13 +03:00
|
|
|
bool
|
|
|
|
RGBColor::operator==(const RGBColor &color) const
|
2002-12-31 21:21:14 +03:00
|
|
|
{
|
2006-02-06 14:47:13 +03:00
|
|
|
return fColor32.red == color.fColor32.red
|
|
|
|
&& fColor32.green == color.fColor32.green
|
|
|
|
&& fColor32.blue == color.fColor32.blue
|
|
|
|
&& fColor32.alpha == color.fColor32.alpha;
|
2005-06-03 23:31:26 +04:00
|
|
|
}
|
|
|
|
|
2006-02-06 14:47:13 +03:00
|
|
|
|
2006-05-19 19:52:21 +04:00
|
|
|
bool
|
|
|
|
RGBColor::operator!=(const rgb_color &color) const
|
|
|
|
{
|
|
|
|
return fColor32.red != color.red
|
|
|
|
|| fColor32.green != color.green
|
|
|
|
|| fColor32.blue != color.blue
|
|
|
|
|| fColor32.alpha != color.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
RGBColor::operator!=(const RGBColor &color) const
|
|
|
|
{
|
|
|
|
return fColor32.red != color.fColor32.red
|
|
|
|
|| fColor32.green != color.fColor32.green
|
|
|
|
|| fColor32.blue != color.fColor32.blue
|
|
|
|
|| fColor32.alpha != color.fColor32.alpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-06-03 23:31:26 +04:00
|
|
|
bool
|
|
|
|
RGBColor::IsTransparentMagic() const
|
|
|
|
{
|
|
|
|
// TODO: validate this for B_CMAP8 for example
|
|
|
|
return *this == B_TRANSPARENT_COLOR;
|
2002-12-31 21:21:14 +03:00
|
|
|
}
|