/home/neoflo/smb4k/SERVEUR/Millie/trunk/src/ImageHSL.cpp

Aller à la documentation de ce fichier.
00001 /******************************************************************************
00002  *       __    _    _   _       _       _   _____                             *
00003  *       | \  / |  | | | |     | |     | |  | ___|                            *
00004  *       |  \/  |  | | | |     | |     | |  | |_                              *
00005  *       |      |  | | | |     | |     | |  |  _|                             *
00006  *       | |\/| |  | | | |__   | |__   | |  | |__                             *
00007  *       |_|  |_|  |_| |____|  |____|  |_|  |____|                            *
00008  * __________________________________________________________________________ *
00009  *                 Multifunctional Library For Image Processing               *
00010  *                                                                            *
00011  *                                                                            *
00012  *                                                                            *
00013  *      (c) Copyright 2007 by Humbert Florent                                 *
00014  *                                                                            *
00015  *      This program is free software; you can redistribute it and/or modify  *
00016  *      it under the terms of the GNU General Public License as published by  *
00017  *      the Free Software Foundation; only version 2 of the License.          *
00018  *                                                                            *
00019  *      This program is distributed in the hope that it will be useful,       *
00020  *      but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00021  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00022  *      GNU General Public License for more details.                          *
00023  *                                                                            *
00024  *      You should have received a copy of the GNU General Public License     *
00025  *      along with this program; if not, write to the Free Software           *
00026  *      Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA             *
00027  *      02111-1307, USA.                                                      *
00028  ******************************************************************************/
00029 
00032 #include "ImageHSL.hpp"
00033 
00034 #include <iostream>
00035 
00036 using namespace Millie;
00037 
00038 ImageHSL::ImageHSL(int largeur, int hauteur) :
00039     TImage<float>(largeur, hauteur, 3)
00040 {}
00041 
00042 ImageHSL::ImageHSL() : TImage<float>(3)
00043 {}
00044 
00045 ImageHSL::~ImageHSL()
00046 {
00047 }
00048 
00055 float ImageHSL::getLightnessPixel(int x, int y) const
00056 {
00057   return getPixel(x, y, 2);
00058 }
00059 void  ImageHSL::setLightnessPixel(int x, int y, float value)
00060 {
00061   setPixel(x, y, 2, value);
00062 }
00063 float ImageHSL::getHuePixel(int x, int y) const
00064 {
00065   return getPixel(x, y, 0);
00066 }
00067 void ImageHSL::setHuePixel(int x, int y, float value)
00068 {
00069   setPixel(x, y, 0, value);
00070 }
00071 float ImageHSL::getSaturationPixel(int x, int y) const
00072 {
00073   return getPixel(x, y, 1);
00074 }
00075 void ImageHSL::setSaturationPixel(int x, int y, float value)
00076 {
00077   return setPixel(x, y, 1, value);
00078 }
00079 
00080 
00081 void ImageHSL::addToLightness(int value)
00082 {
00083   for(int y = 0; y<getHeight(); y++)
00084     for(int x = 0; x<getWidth(); x++)
00085     {
00086       float tempo = getLightnessPixel(x,y);
00087       tempo += value/100.0f;
00088       tempo = std::min(1.0f, tempo);
00089       tempo = std::max(0.0f,tempo);
00090       setLightnessPixel(x,y, tempo);
00091     }
00092 }
00093 
00094 void ImageHSL::addToSaturation(int value)
00095 {
00096   for(int y = 0; y<getHeight(); y++)
00097     for(int x = 0; x<getWidth(); x++)
00098     {
00099       float tempo = getSaturationPixel(x,y);
00100       tempo += value/100.0f;
00101       tempo = std::min(1.0f, tempo);
00102       tempo = std::max(0.0f,tempo);
00103       setSaturationPixel(x,y, tempo);
00104     }
00105 }
00106 
00107 
00108 void ImageHSL::addToHue(int value)
00109 {
00110   if(value< -180.0f || value>180.0f)
00111     throw OutOfRange("addToHue");
00112 
00113   for(int y = 0; y<getHeight(); y++)
00114     for(int x = 0; x<getWidth(); x++)
00115     {
00116       float tempo = getHuePixel(x,y);
00117       tempo += value;
00118       if(tempo>360.0f)
00119         tempo -= 360.0f;
00120       if(tempo<0.0f)
00121         ;
00122       tempo += 360.0f;
00123 
00124       setHuePixel(x,y, tempo);
00125     }
00126 }

Généré le Fri May 18 23:24:33 2007 pour Millie par  doxygen 1.5.1