diff --git a/imageviewer-qt4.cpp b/imageviewer-qt4.cpp index 2add697..972da2e 100644 --- a/imageviewer-qt4.cpp +++ b/imageviewer-qt4.cpp @@ -286,6 +286,31 @@ void ImageViewer::adjustBrightness(int b) { renewLogging(); } +/** + * Fired by the constrast_slider, this one adjusts the contrast on image. + * @brief ImageViewer::adjustContrast + */ +void ImageViewer::adjustContrast(int c) { + int h, s, old_l; + int new_l = 0; + int delta = c - 255; + for(int x=0; xwidth(); x++) { + for(int y=0; yheight(); y++) { +// QColor color = QColor::fromRgb(original_image->pixel(x, y)); +// color.getHsl(&h, &s, &old_l); +// new_l = old_l + delta; +// if(new_l > 255) new_l = 255; +// if(new_l < 0) new_l = 0; +// color.setHsl(h, s, new_l); +// image->setPixel(x, y, color.rgba()); + } + } + updateImageDisplay(); + logFile << "[TODO!] Contrast adjusted to: " << old_l << " + " << delta << " -> (" << h << ", " << s << ", " << new_l << ")" << std::endl; + renewLogging(); +} + + /**************************************************************************************** * * GUI elements related to the tasks are set up here. @@ -353,8 +378,9 @@ void ImageViewer::generateControlPanels() { contrast_slider = new QSlider(Qt::Horizontal); contrast_slider->setMinimum(0); - contrast_slider->setMaximum(255); - contrast_slider->setValue(127); + contrast_slider->setMaximum(510); + contrast_slider->setValue(255); + QObject::connect(contrast_slider, SIGNAL(valueChanged(int)), this, SLOT (adjustContrast(int))); task_tab2->addWidget(task_tab2_stats); task_tab2->addWidget(new QLabel("Histogramm")); diff --git a/imageviewer-qt4.h b/imageviewer-qt4.h index e108d64..243758b 100644 --- a/imageviewer-qt4.h +++ b/imageviewer-qt4.h @@ -108,6 +108,7 @@ class ImageViewer : public QMainWindow { void analyzeImage(); void updateHistogramm(); void adjustBrightness(int b); + void adjustContrast(int c); void open(); void print();