Skip to content

Commit

Permalink
workspace drawing - vulkan api segmentation bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
0xMartin committed Feb 12, 2024
1 parent 0469df5 commit 9ac8286
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
2 changes: 1 addition & 1 deletion BMPEditor/CMakeLists.txt.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 12.0.2, 2024-02-12T09:42:06. -->
<!-- Written by QtCreator 12.0.2, 2024-02-12T22:13:04. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
Expand Down
13 changes: 10 additions & 3 deletions BMPEditor/Editor/imagehistogramwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,26 @@ 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]);
int b = (int)(image->pixels[i + 2]);
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()
Expand Down
26 changes: 14 additions & 12 deletions BMPEditor/Editor/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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-------------------------

/****************************************************************************************************************/
Expand Down

0 comments on commit 9ac8286

Please sign in to comment.