- now correctly shows multiple images in the image viewer. Thanks Claude!

This commit is contained in:
iceman1001
2026-08-21 19:41:27 +02:00
parent 9310f93df6
commit 68af7e2582
9 changed files with 224 additions and 179 deletions
+41 -20
View File
@@ -66,39 +66,60 @@ extern "C" void RepaintGraphWindow(void) {
}
// Show a notice if X11/XQuartz isn't available
static void show_no_gui_notice(void) {
#if defined(__MACH__) && defined(__APPLE__)
PrintAndLogEx(WARNING, "You appear to be on a MacOS device without XQuartz.\nYou may need to install XQuartz (https://www.xquartz.org/) to make the plot work.");
#else
PrintAndLogEx(WARNING, "You appear to be on an environment without an X11 server or without DISPLAY environment variable set.\nPicture display may not work until you resolve these issues.");
#endif
}
// hook up picture viewer
extern "C" void ShowPictureWindow(uint8_t *data, int len) {
extern "C" void ShowPictureWindow(const char *title, uint8_t *data, int len) {
// No support for jpeg2000 in Qt Image since a while...
// https://doc.qt.io/qt-5/qtimageformats-index.html
QImage img = QImage::fromData(data, len);
if (img.isNull()) {
return;
}
if (!gui) {
// Show a notice if X11/XQuartz isn't available
#if defined(__MACH__) && defined(__APPLE__)
PrintAndLogEx(WARNING, "You appear to be on a MacOS device without XQuartz.\nYou may need to install XQuartz (https://www.xquartz.org/) to make the plot work.");
#else
PrintAndLogEx(WARNING, "You appear to be on an environment without an X11 server or without DISPLAY environment variable set.\nPicture display may not work until you resolve these issues.");
#endif
PrintAndLogEx(WARNING, "Failed to decode image ( %s ), Qt lacks support for this format (jpeg2000?)", (title) ? title : "n/a");
return;
}
gui->ShowPictureWindow(img);
if (!gui) {
show_no_gui_notice();
return;
}
gui->ShowPictureWindow(QString::fromUtf8((title) ? title : ""), img);
}
extern "C" void ShowBase64PictureWindow(char *b64) {
if (!gui) {
// Show a notice if X11/XQuartz isn't available
#if defined(__MACH__) && defined(__APPLE__)
PrintAndLogEx(WARNING, "You appear to be on a MacOS device without XQuartz.\nYou may need to install XQuartz (https://www.xquartz.org/) to make the plot work.");
#else
PrintAndLogEx(WARNING, "You appear to be on an environment without an X11 server or without DISPLAY environment variable set.\nPlot may not work until you resolve these issues.");
#endif
extern "C" void ShowBase64PictureWindow(const char *title, char *b64) {
if (b64 == NULL) {
return;
}
gui->ShowBase64PictureWindow(b64);
// decode here, in the caller thread, since the b64 pointer isn't
// guaranteed to be alive once the GUI thread picks up the queued signal
QImage img;
if (img.loadFromData(QByteArray::fromBase64(QByteArray(b64))) == false) {
PrintAndLogEx(WARNING, "Failed to decode base64 image ( %s )", (title) ? title : "n/a");
return;
}
if (!gui) {
show_no_gui_notice();
return;
}
gui->ShowPictureWindow(QString::fromUtf8((title) ? title : ""), img);
}
extern "C" void ClearPictureWindow(void) {
if (!gui)
return;
gui->ClearPictureWindow();
}
extern "C" void HidePictureWindow(void) {