00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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 }