diff --git a/BMPEditor/CMakeLists.txt.user b/BMPEditor/CMakeLists.txt.user index 0648363..7d2284d 100644 --- a/BMPEditor/CMakeLists.txt.user +++ b/BMPEditor/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/BMPEditor/Editor/imagehistogramwidget.cpp b/BMPEditor/Editor/imagehistogramwidget.cpp index e82e975..461dbb9 100644 --- a/BMPEditor/Editor/imagehistogramwidget.cpp +++ b/BMPEditor/Editor/imagehistogramwidget.cpp @@ -66,8 +66,13 @@ void ImageHistogramWidget::computeHistogram() { histogramRed.resize(256, 0); histogramGreen.resize(256, 0); histogramBlue.resize(256, 0); + maxFrequency = 0; + int maxR = 0; + int maxG = 0; + int maxB = 0; + for (size_t i = 0; i < image->dataLen; i += 3) { int r = (int)(image->pixels[i]); int g = (int)(image->pixels[i + 1]); @@ -75,10 +80,12 @@ void ImageHistogramWidget::computeHistogram() { histogramRed[r]++; histogramGreen[g]++; histogramBlue[b]++; - maxFrequency = std::max(maxFrequency, histogramRed[r]); - maxFrequency = std::max(maxFrequency, histogramGreen[g]); - maxFrequency = std::max(maxFrequency, histogramBlue[b]); + maxR = std::max(maxR, histogramRed[r]); + maxG = std::max(maxG, histogramGreen[g]); + maxB = std::max(maxB, histogramBlue[b]); } + + maxFrequency = (int)((maxR + maxG + maxB) / 3.0); } void ImageHistogramWidget::updateDone() diff --git a/BMPEditor/Editor/workspace.cpp b/BMPEditor/Editor/workspace.cpp index d4b5dea..203fc7b 100644 --- a/BMPEditor/Editor/workspace.cpp +++ b/BMPEditor/Editor/workspace.cpp @@ -255,18 +255,20 @@ void Workspace::paintEvent(QPaintEvent *event) { /****************************************************************************************************************/ //-------OBRAZEK------------------------- - painter.save(); - // aplikace offsetu - painter.translate(offset); - // aplikace scale - painter.scale(this->scale, this->scale); - // vykresleni obrazku - this->image->paintEvent(painter); - // vraceni zpet do puvodniho stavu - painter.restore(); - // outline - painter.setPen(Qt::black); - painter.drawRect(offset.x(), offset.y(), this->image->width * this->scale, this->image->height * this->scale); + if(this->isEnabled()) { + painter.save(); + // aplikace offsetu + painter.translate(offset); + // aplikace scale + painter.scale(this->scale, this->scale); + // vykresleni obrazku + this->image->paintEvent(painter); + // vraceni zpet do puvodniho stavu + painter.restore(); + // outline + painter.setPen(Qt::black); + painter.drawRect(offset.x(), offset.y(), this->image->width * this->scale, this->image->height * this->scale); + } //-------OBRAZEK------------------------- /****************************************************************************************************************/