mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2026-09-26 13:48:09 +00:00
- now correctly shows multiple images in the image viewer. Thanks Claude!
This commit is contained in:
+41
-20
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user