From 554cbc9a8338658bea0c230c84c7ddcd0ebe6678 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 13 May 2017 10:50:28 +0200 Subject: [PATCH] Implement the coordinate display in the analyzer. --- analyzer.cpp | 6 +++++- ui_analyzer.ui | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/analyzer.cpp b/analyzer.cpp index 90d61ac..7e1b4c6 100644 --- a/analyzer.cpp +++ b/analyzer.cpp @@ -227,12 +227,16 @@ bool Analyzer::eventFilter(QObject *watched, QEvent *event) int y = lrint(mouse_event->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)))); - char buf[256]; snprintf(buf, sizeof(buf), "#%02x%02x%02x", qRed(pixel), qGreen(pixel), qBlue(pixel)); ui->hex_label->setText(buf); } diff --git a/ui_analyzer.ui b/ui_analyzer.ui index eba57ca..15e8e79 100644 --- a/ui_analyzer.ui +++ b/ui_analyzer.ui @@ -220,7 +220,7 @@ - Selected coordinate (x,y): (123,456) + Selected coordinate (x,y): (none) Qt::AlignCenter -- 2.39.2