00001 /// \file 00002 /// Définition de la classe Pixel 00003 #include "Pixel.hpp" 00004 /////////////////////////////////////////////////////////////////////////////// 00005 /// Pixel 00006 /////////////////////////////////////////////////////////////////////////////// 00007 Pixel::Pixel(){ 00008 p = new Pixel_Base(); 00009 } 00010 Pixel::Pixel(int x, int y, Color color){ 00011 p = new Pixel_Base(x, y, color); 00012 } 00013 Pixel::Pixel(const Pixel& pixel){ 00014 p = pixel.p; 00015 ++p->use; 00016 } 00017 Pixel& Pixel::operator=(const Pixel& rhs){ 00018 rhs.p->use++; 00019 if(--p->use == 0){ 00020 delete p; 00021 } 00022 p = rhs.p; 00023 return *this; 00024 } 00025 Pixel::~Pixel(){ 00026 if(--p->use == 0){ 00027 delete p; 00028 } 00029 } 00030 int Pixel::getX()const{ 00031 return p->getX(); 00032 } 00033 int Pixel::getY()const{ 00034 return p->getY(); 00035 } 00036 void Pixel::setColor(Color color){ 00037 p->setColor(color); 00038 } 00039 Color Pixel::getColor()const{ 00040 return p->getColor(); 00041 } 00042 string Pixel::toString() const{ 00043 return p->toString(); 00044 } 00045 /////////////////////////////////////////////////////////////////////////////// 00046 /// Pixel_Base 00047 /////////////////////////////////////////////////////////////////////////////// 00048 string Pixel_Base::toString()const{ 00049 ostringstream o; 00050 o << "[" << x << ":" << y << "]" << color.toString(); 00051 return o.str(); 00052 }