[TASK] Add skeleton method for contrast slider.

This commit is contained in:
Jan Philipp Timme 2015-11-06 13:57:03 +01:00
parent 99f6b596a1
commit 6829814936
2 changed files with 29 additions and 2 deletions

View File

@ -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; x<image->width(); x++) {
for(int y=0; y<image->height(); 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"));

View File

@ -108,6 +108,7 @@ class ImageViewer : public QMainWindow {
void analyzeImage();
void updateHistogramm();
void adjustBrightness(int b);
void adjustContrast(int c);
void open();
void print();