From e287886dfb24cb10e82357c9f905ab14e75b2812 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 7 Jul 2022 16:09:50 +0600 Subject: [PATCH] Implement multi-monitor screenshots --- src/qt/qt_d3d9renderer.cpp | 2 +- src/qt/qt_mainwindow.cpp | 3 ++- src/qt/qt_rendererstack.cpp | 4 ++-- src/video/video.c | 6 ++++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/qt/qt_d3d9renderer.cpp b/src/qt/qt_d3d9renderer.cpp index 551b4d8ac..3a8001be4 100644 --- a/src/qt/qt_d3d9renderer.cpp +++ b/src/qt/qt_d3d9renderer.cpp @@ -153,7 +153,7 @@ void D3D9Renderer::blit(int x, int y, int w, int h) srcRect.right = source.right(); if (screenshots) { - video_screenshot((uint32_t *) &(buffer32->line[y][x]), 0, 0, 2048); + video_screenshot_monitor((uint32_t *) &(monitors[m_monitor_index].target_buffer->line[y][x]), 0, 0, 2048, m_monitor_index); } if (SUCCEEDED(d3d9surface->LockRect(&lockRect, &srcRect, 0))) { for (int y1 = 0; y1 < h; y1++) { diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 16b5271d4..11ad7ca61 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -1925,7 +1925,8 @@ void MainWindow::on_actionUpdate_status_bar_icons_triggered() void MainWindow::on_actionTake_screenshot_triggered() { startblit(); - screenshots++; + for (int i = 0; i < MONITORS_NUM; i++) + monitors[i].mon_screenshots++; endblit(); device_force_redraw(); } diff --git a/src/qt/qt_rendererstack.cpp b/src/qt/qt_rendererstack.cpp index 36d76c1ed..3082c8a73 100644 --- a/src/qt/qt_rendererstack.cpp +++ b/src/qt/qt_rendererstack.cpp @@ -437,8 +437,8 @@ RendererStack::blitCommon(int x, int y, int w, int h) video_copy(scanline, &(monitors[m_monitor_index].target_buffer->line[y1][x]), w * 4); } - if (screenshots) { - video_screenshot((uint32_t *) imagebits, x, y, 2048); + if (monitors[m_monitor_index].mon_screenshots) { + video_screenshot_monitor((uint32_t *) imagebits, x, y, 2048, m_monitor_index); } video_blit_complete_monitor(m_monitor_index); emit blitToRenderer(currentBuf, sx, sy, sw, sh); diff --git a/src/video/video.c b/src/video/video.c index 1c8312982..ec56c574c 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -420,7 +420,7 @@ video_take_screenshot_monitor(const char *fn, uint32_t *buf, int start_x, int st void video_screenshot_monitor(uint32_t *buf, int start_x, int start_y, int row_len, int monitor_index) { - char path[1024], fn[128]; + char path[1024], fn[256]; memset(fn, 0, sizeof(fn)); memset(path, 0, sizeof(path)); @@ -431,6 +431,8 @@ video_screenshot_monitor(uint32_t *buf, int start_x, int start_y, int row_len, i plat_dir_create(path); path_slash(path); + strcat(path, "Monitor_"); + snprintf(&path[strlen(path)], 42, "%d_", monitor_index + 1); plat_tempfile(fn, NULL, ".png"); strcat(path, fn); @@ -446,7 +448,7 @@ video_screenshot_monitor(uint32_t *buf, int start_x, int start_y, int row_len, i void video_screenshot(uint32_t *buf, int start_x, int start_y, int row_len) { - video_screenshot_monitor(buf, start_x, start_y, row_len, monitor_index_global); + video_screenshot_monitor(buf, start_x, start_y, row_len, 0); }