|
9 | 9 | #include "Emu/system_config.h" |
10 | 10 | #include "Emu/IdManager.h" |
11 | 11 | #include "Emu/Cell/Modules/cellScreenshot.h" |
| 12 | +#include "Emu/RSX/rsx_utils.h" |
12 | 13 |
|
13 | 14 | #include <QCoreApplication> |
14 | 15 | #include <QDateTime> |
@@ -442,6 +443,8 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot |
442 | 443 | std::thread( |
443 | 444 | [sshot_width, sshot_height, is_bgra](const std::vector<u8> sshot_data) |
444 | 445 | { |
| 446 | + screenshot_log.notice("Taking screenshot (%dx%d)", sshot_width, sshot_height); |
| 447 | + |
445 | 448 | std::string screen_path = fs::get_config_dir() + "screenshots/"; |
446 | 449 |
|
447 | 450 | if (!fs::create_dir(screen_path) && fs::g_tls_error != fs::error::exist) |
@@ -571,12 +574,34 @@ void gs_frame::take_screenshot(const std::vector<u8> sshot_data, const u32 sshot |
571 | 574 | if (!overlay_img.load(qstr(cell_sshot_overlay_path))) |
572 | 575 | { |
573 | 576 | screenshot_log.error("Failed to read cell screenshot overlay '%s' : %s", cell_sshot_overlay_path, fs::g_tls_error); |
| 577 | + return; |
| 578 | + } |
| 579 | + |
| 580 | + // Games choose the overlay file and the offset based on the current video resolution. |
| 581 | + // We need to scale the overlay if our resolution scaling causes the image to have a different size. |
| 582 | + const auto avconf = g_fxo->get<rsx::avconf>(); |
| 583 | + |
| 584 | + // TODO: handle wacky PS3 resolutions (without resolution scaling) |
| 585 | + if (avconf->resolution_x != sshot_width || avconf->resolution_y != sshot_height) |
| 586 | + { |
| 587 | + const int scale = rsx::get_resolution_scale_percent(); |
| 588 | + const int x = (scale * manager.overlay_offset_x) / 100; |
| 589 | + const int y = (scale * manager.overlay_offset_y) / 100; |
| 590 | + const int width = (scale * overlay_img.width()) / 100; |
| 591 | + const int height = (scale * overlay_img.height()) / 100; |
| 592 | + |
| 593 | + screenshot_log.notice("Scaling overlay from %dx%d at offset (%d,%d) to %dx%d at offset (%d,%d)", |
| 594 | + overlay_img.width(), overlay_img.height(), manager.overlay_offset_x, manager.overlay_offset_y, width, height, x, y); |
| 595 | + |
| 596 | + manager.overlay_offset_x = x; |
| 597 | + manager.overlay_offset_y = y; |
| 598 | + overlay_img = overlay_img.scaled(QSize(width, height), Qt::AspectRatioMode::IgnoreAspectRatio, Qt::TransformationMode::SmoothTransformation); |
574 | 599 | } |
575 | | - // TODO: the overlay and its offset need to be scaled based on image size, resolution scaling and video resolution |
576 | | - else if (manager.overlay_offset_x < static_cast<s64>(sshot_width) |
577 | | - && manager.overlay_offset_y < static_cast<s64>(sshot_height) |
578 | | - && manager.overlay_offset_x + overlay_img.width() > 0 |
579 | | - && manager.overlay_offset_y + overlay_img.height() > 0) |
| 600 | + |
| 601 | + if (manager.overlay_offset_x < static_cast<s64>(sshot_width) && |
| 602 | + manager.overlay_offset_y < static_cast<s64>(sshot_height) && |
| 603 | + manager.overlay_offset_x + overlay_img.width() > 0 && |
| 604 | + manager.overlay_offset_y + overlay_img.height() > 0) |
580 | 605 | { |
581 | 606 | QImage screenshot_img(rows[0], sshot_width, sshot_height, QImage::Format_RGBA8888); |
582 | 607 | QPainter painter(&screenshot_img); |
|
0 commit comments