mirror of
https://github.com/azahar-emu/azahar
synced 2025-11-07 07:29:58 +01:00
qt: For Qt 6.9.0 and above, use QImage::flipped over QImage::mirrored
The latter has been deprecated, and is causing build failures where deprecations warnings are treated as errors.
This commit is contained in:
parent
8d769ed9cb
commit
e341dcf238
@ -10,6 +10,7 @@
|
||||
#include <QWindow>
|
||||
#include "citra_qt/bootmanager.h"
|
||||
#include "citra_qt/citra_qt.h"
|
||||
#include "citra_qt/util/util.h"
|
||||
#include "common/color.h"
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scm_rev.h"
|
||||
@ -714,7 +715,7 @@ void GRenderWindow::CaptureScreenshot(u32 res_scale, const QString& screenshot_p
|
||||
screenshot_image.bits(),
|
||||
[this, screenshot_path](bool invert_y) {
|
||||
const std::string std_screenshot_path = screenshot_path.toStdString();
|
||||
if (screenshot_image.mirrored(false, invert_y).save(screenshot_path)) {
|
||||
if (GetMirroredImage(screenshot_image, false, invert_y).save(screenshot_path)) {
|
||||
LOG_INFO(Frontend, "Screenshot saved to \"{}\"", std_screenshot_path);
|
||||
} else {
|
||||
LOG_ERROR(Frontend, "Failed to save screenshot to \"{}\"", std_screenshot_path);
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <cstring>
|
||||
#include <QImage>
|
||||
#include "citra_qt/camera/camera_util.h"
|
||||
#include "citra_qt/util/util.h"
|
||||
|
||||
namespace CameraUtil {
|
||||
|
||||
@ -213,9 +214,9 @@ std::vector<u16> ProcessImage(const QImage& image, int width, int height, bool o
|
||||
}
|
||||
QImage scaled =
|
||||
image.scaled(width, height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||
QImage transformed =
|
||||
scaled.copy((scaled.width() - width) / 2, (scaled.height() - height) / 2, width, height)
|
||||
.mirrored(flip_horizontal, flip_vertical);
|
||||
QImage transformed = GetMirroredImage(
|
||||
scaled.copy((scaled.width() - width) / 2, (scaled.height() - height) / 2, width, height),
|
||||
flip_horizontal, flip_vertical);
|
||||
if (output_rgb) {
|
||||
QImage converted = transformed.convertToFormat(QImage::Format_RGB16);
|
||||
std::memcpy(buffer.data(), converted.bits(), width * height * sizeof(u16));
|
||||
|
||||
@ -175,3 +175,19 @@ const std::string GetApplicationsDirectory() {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation).toStdString();
|
||||
#endif
|
||||
}
|
||||
|
||||
QImage GetMirroredImage(QImage source_image, bool flip_horizontal, bool flip_vertical) {
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0) // Fallback, uses deprecated method
|
||||
return source_image.mirrored(flip_horizontal, flip_vertical);
|
||||
#else // New method
|
||||
auto orientation_horizontal = static_cast<Qt::Orientations>(0x0);
|
||||
auto orientation_vertical = static_cast<Qt::Orientations>(0x0);
|
||||
|
||||
if (flip_horizontal)
|
||||
orientation_horizontal = Qt::Horizontal;
|
||||
if (flip_vertical)
|
||||
orientation_vertical = Qt::Vertical;
|
||||
|
||||
return source_image.flipped(orientation_horizontal | orientation_vertical);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -41,3 +41,11 @@ QPixmap GetQPixmapFromSMDH(const std::vector<u8>& smdh_data);
|
||||
* @return The user’s applications directory
|
||||
*/
|
||||
[[nodiscard]] const std::string GetApplicationsDirectory();
|
||||
|
||||
/**
|
||||
* Imitates the deprecated `QImage::mirrored` function in a forwards-compatible manner
|
||||
* @param flip_horizontal Whether the image should be flipped horizontally
|
||||
* @param flip_vertical Whether the image should be flipped vertically
|
||||
* @return QImage The mirrored image
|
||||
*/
|
||||
QImage GetMirroredImage(QImage source_image, bool flip_horizontal, bool flip_vertical);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user