Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

color.cpp

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2002 Xavier Trochu
00003 
00004 This software is provided 'as-is', without any express or implied warranty. In no event
00005 will the authors be held liable for any damages arising from the use of this software.
00006 
00007 Permission is granted to anyone to use this software for any purpose, including commercial
00008 applications, and to alter it and redistribute it freely, subject to the following
00009 restrictions:
00010 
00011 1. The origin of this software must not be misrepresented; you must not claim that you
00012    wrote the original software. If you use this software in a product, an acknowledgment
00013    in the product documentation would be appreciated but is not required.
00014 
00015 2. Altered source versions must be plainly marked as such, and must not be misrepresented 
00016    as being the original software.
00017 
00018 3. This notice may not be removed or altered from any source distribution.
00019 */
00020 #include <algorithm>
00021 #include "color.h"
00022 
00023 using namespace std;
00024 
00025 color::color() throw() : _r(0), _g(0), _b(0) {
00026 }
00027 
00028 color::color(value_type r, value_type g, value_type b) throw() : _r(r), _g(g), _b(b) {
00029 }
00030 
00031 color::color(const color & c) throw() : _r(c._r), _g(c._g), _b(c._b) {
00032 }
00033 
00034 color::color & color::operator=(const color & c) {
00035     _r = c._r;
00036     _g = c._g;
00037     _b = c._b;
00038     return *this;
00039 }
00040 
00041 color::~color() throw() {
00042 }
00043 
00044 color::value_type color::red() const throw() { 
00045     return _r; 
00046 }
00047 
00048 color::value_type color::green() const throw() { 
00049     return _g; 
00050 }
00051 
00052 color::value_type color::blue() const throw() { 
00053     return _b;
00054 }
00055 
00056 void color::delta(short * ptr) throw() {
00057     // This is a very specific method for XPALs.
00058     int t;
00059     t = ((static_cast<int>(_r) << 7) + _r + ptr[0]) >> 7;
00060     _r = max(min(255, t), 0);
00061     t = ((static_cast<int>(_g) << 7) + _g + ptr[1]) >> 7;
00062     _g = max(min(255, t), 0);
00063     t = ((static_cast<int>(_b) << 7) + _b + ptr[2]) >> 7;
00064     _b = max(min(255, t), 0);
00065 }
00066 
00067 ostream & operator <<(ostream & o, const color & c) {
00068     o << "COLOR(" << static_cast<int>(c.red()) << ", " << static_cast<int>(c.green()) << ", " << static_cast<int>(c.blue()) << ")";
00069     return o;
00070 }
00071 

Generated on Fri Aug 9 22:54:29 2002 for san_player by doxygen1.2.16