From 68694e3d73c3ffa6b2c5f8f9c6005f77d819cce8 Mon Sep 17 00:00:00 2001 From: Geoffrey Frogeye Date: Thu, 22 May 2014 21:26:51 +0200 Subject: [PATCH] Corrections des commandes couleurs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Luminosité & Saturation : multiplication au lieu d'addition * Le zéro de saturation était mal géré --- README.md | 2 +- src/traitementImage.cpp | 4 ++-- src/utilitaires.cpp | 11 +++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 3614e9b..b1c15b7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Nos noms complets et le nom du lycée sont masqués pour des raisons d'intimité ###Le programme Ce programme est un éditeur basique d'images [PBM/PGM/PPM](http://fr.wikipedia.org/wiki/Portable_pixmap) s’exécutant en ligne de commande. -*Version :* v1.0.0 +*Version :* v1.0.1 *Status :* [![Build Status](https://travis-ci.org/GeoffreyFrogeye/PILG.svg?branch=master)](https://travis-ci.org/GeoffreyFrogeye/PILG) diff --git a/src/traitementImage.cpp b/src/traitementImage.cpp index 0ee3e6d..b34511c 100644 --- a/src/traitementImage.cpp +++ b/src/traitementImage.cpp @@ -398,7 +398,7 @@ int saturation(Image entree, Image &sortie, for (int y = 0; y < sortie.g_dimensionY(); y++) { entree.g_pixel(x, y, pixel); rvb2tsl(pixel, tsl); - tsl.s += saturation; + tsl.s *= saturation; tsl.s = tsl.s > 1 ? 1 : (tsl.s < 0 ? 0 : tsl.s); tsl2rvb(tsl, pixel); sortie.s_pixel(x, y, pixel); @@ -418,7 +418,7 @@ int luminosite(Image entree, Image &sortie, for (int y = 0; y < sortie.g_dimensionY(); y++) { entree.g_pixel(x, y, pixel); rvb2tsl(pixel, tsl); - tsl.l += luminosite; + tsl.l *= luminosite; tsl.l = tsl.l > 1 ? 1 : (tsl.l < 0 ? 0 : tsl.l); tsl2rvb(tsl, pixel); sortie.s_pixel(x, y, pixel); diff --git a/src/utilitaires.cpp b/src/utilitaires.cpp index eb7e0f5..04494e1 100644 --- a/src/utilitaires.cpp +++ b/src/utilitaires.cpp @@ -66,14 +66,14 @@ int tsl2rvb(TSL entree, Pixel &sortie) { } if (entree.s == 0) { - fill_n(c, 3, entree.l * 255); + fill_n(c, 3, entree.l); } else { fill_n(t3, 3, 0); fill_n(c, 3, 0); t2 = entree.l < 0.5 ? entree.l * (1 + entree.s) : entree.l + entree.s - entree.l * entree.s; t1 = 2 * entree.l - t2; - entree.t /= 360; + entree.t /= 360.0; t3[0] = entree.t + 1 / 3.0; t3[1] = entree.t; t3[2] = entree.t - 1 / 3.0; @@ -97,12 +97,11 @@ int tsl2rvb(TSL entree, Pixel &sortie) { c[i] = t1; } } - - sortie.r = c[0] * sortie.maxComposante; - sortie.v = c[1] * sortie.maxComposante; - sortie.b = c[2] * sortie.maxComposante; } + sortie.r = c[0] * sortie.maxComposante; + sortie.v = c[1] * sortie.maxComposante; + sortie.b = c[2] * sortie.maxComposante; return 0; }