]> git.sesse.net Git - nageru/blobdiff - nageru/analyzer.cpp
Bump bmusb submodule (no real changes for us).
[nageru] / nageru / analyzer.cpp
index bdb80bc31b52c46d98ee4540220c606e706fd594..f2d3ae699cf8a0d1e12ca4394f23aac2f95e0197 100644 (file)
@@ -41,7 +41,7 @@ Analyzer::Analyzer()
        context = create_context(surface);
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        grab_timer.setSingleShot(true);
@@ -96,7 +96,7 @@ void Analyzer::mixer_shutting_down()
 
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
        glDeleteBuffers(1, &pbo);
        check_error();
@@ -111,7 +111,7 @@ void Analyzer::grab_clicked()
 
        if (!make_current(context, surface)) {
                printf("oops\n");
-               exit(1);
+               abort();
        }
 
        Mixer::DisplayFrame frame;
@@ -267,25 +267,23 @@ bool Analyzer::eventFilter(QObject *watched, QEvent *event)
 
 void Analyzer::grab_pixel(int x, int y)
 {
-       const QPixmap *pixmap = ui->grabbed_frame_label->pixmap();
-       if (pixmap != nullptr) {
-               x = lrint(x * double(pixmap->width()) / ui->grabbed_frame_label->width());
-               y = lrint(y * double(pixmap->height()) / ui->grabbed_frame_label->height());
-               x = std::min(x, pixmap->width() - 1);
-               y = std::min(y, pixmap->height() - 1);
-
-               char buf[256];
-               snprintf(buf, sizeof(buf), "Selected coordinate (x,y): (%d,%d)", x, y);
-               ui->coord_label->setText(buf);
-
-               QRgb pixel = grabbed_image.pixel(x, y);
-               ui->red_label->setText(QString::fromStdString(to_string(qRed(pixel))));
-               ui->green_label->setText(QString::fromStdString(to_string(qGreen(pixel))));
-               ui->blue_label->setText(QString::fromStdString(to_string(qBlue(pixel))));
-
-               snprintf(buf, sizeof(buf), "#%02x%02x%02x", qRed(pixel), qGreen(pixel), qBlue(pixel));
-               ui->hex_label->setText(buf);
-       }
+       QPixmap pixmap = ui->grabbed_frame_label->pixmap(Qt::ReturnByValue);
+       x = lrint(x * double(pixmap.width()) / ui->grabbed_frame_label->width());
+       y = lrint(y * double(pixmap.height()) / ui->grabbed_frame_label->height());
+       x = std::min(x, pixmap.width() - 1);
+       y = std::min(y, pixmap.height() - 1);
+
+       char buf[256];
+       snprintf(buf, sizeof(buf), "Selected coordinate (x,y): (%d,%d)", x, y);
+       ui->coord_label->setText(buf);
+
+       QRgb pixel = grabbed_image.pixel(x, y);
+       ui->red_label->setText(QString::fromStdString(to_string(qRed(pixel))));
+       ui->green_label->setText(QString::fromStdString(to_string(qGreen(pixel))));
+       ui->blue_label->setText(QString::fromStdString(to_string(qBlue(pixel))));
+
+       snprintf(buf, sizeof(buf), "#%02x%02x%02x", qRed(pixel), qGreen(pixel), qBlue(pixel));
+       ui->hex_label->setText(buf);
 }
 
 void Analyzer::resizeEvent(QResizeEvent* event)