2018-05-11 17:42:23 +00:00
|
|
|
// Copyright 2018 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include <QImageReader>
|
|
|
|
#include <QMessageBox>
|
|
|
|
#include "citra_qt/camera/still_image_camera.h"
|
|
|
|
|
|
|
|
namespace Camera {
|
|
|
|
|
2018-05-20 01:07:37 +00:00
|
|
|
StillImageCamera::StillImageCamera(QImage image_, const Service::CAM::Flip& flip)
|
2018-05-26 03:26:58 +00:00
|
|
|
: QtCameraInterface(flip), image(std::move(image_)) {}
|
2018-05-11 17:42:23 +00:00
|
|
|
|
|
|
|
void StillImageCamera::StartCapture() {}
|
|
|
|
|
|
|
|
void StillImageCamera::StopCapture() {}
|
|
|
|
|
2018-05-26 03:26:58 +00:00
|
|
|
QImage StillImageCamera::QtReceiveFrame() {
|
|
|
|
return image;
|
2018-05-11 17:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool StillImageCamera::IsPreviewAvailable() {
|
|
|
|
return !image.isNull();
|
|
|
|
}
|
|
|
|
|
2018-06-02 14:13:54 +00:00
|
|
|
const std::string StillImageCameraFactory::GetFilePath() {
|
2018-05-11 17:42:23 +00:00
|
|
|
QList<QByteArray> types = QImageReader::supportedImageFormats();
|
|
|
|
QList<QString> temp_filters;
|
|
|
|
for (QByteArray type : types) {
|
|
|
|
temp_filters << QString("*." + QString(type));
|
|
|
|
}
|
|
|
|
|
2018-05-19 09:03:06 +00:00
|
|
|
QString filter = QObject::tr("Supported image files (%1)").arg(temp_filters.join(" "));
|
2018-05-11 17:42:23 +00:00
|
|
|
return QFileDialog::getOpenFileName(nullptr, QObject::tr("Open File"), ".", filter)
|
|
|
|
.toStdString();
|
|
|
|
}
|
|
|
|
|
2018-05-20 01:07:37 +00:00
|
|
|
std::unique_ptr<CameraInterface> StillImageCameraFactory::Create(
|
|
|
|
const std::string& config, const Service::CAM::Flip& flip) const {
|
2018-05-11 17:42:23 +00:00
|
|
|
std::string real_config = config;
|
|
|
|
if (config.empty()) {
|
2018-06-02 14:13:54 +00:00
|
|
|
real_config = GetFilePath();
|
2018-05-11 17:42:23 +00:00
|
|
|
}
|
|
|
|
QImage image(QString::fromStdString(real_config));
|
|
|
|
if (image.isNull()) {
|
|
|
|
NGLOG_ERROR(Service_CAM, "Couldn't load image \"{}\"", real_config.c_str());
|
|
|
|
}
|
2018-05-20 01:07:37 +00:00
|
|
|
return std::make_unique<StillImageCamera>(image, flip);
|
2018-05-11 17:42:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Camera
|