2020-10-27 13:19:09 +08:00
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "ui_mainwindow.h"
|
|
|
|
|
|
|
|
#include <QImageReader>
|
|
|
|
#include <QDebug>
|
2020-10-31 14:30:29 +08:00
|
|
|
#include <QMimeData>
|
|
|
|
#include <QMouseEvent>
|
2020-10-27 13:19:09 +08:00
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
|
|
: QMainWindow(parent)
|
|
|
|
, ui(new Ui::MainWindow)
|
2020-10-31 14:30:29 +08:00
|
|
|
, m_filePath(R"(E:\16bit-raw-argb-affinityphoto.psd)")
|
2020-10-27 13:19:09 +08:00
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
MainWindow::~MainWindow()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
2020-10-31 14:30:29 +08:00
|
|
|
void MainWindow::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
|
|
|
if (event->mimeData()->hasUrls()) {
|
|
|
|
event->acceptProposedAction();
|
|
|
|
} else {
|
|
|
|
event->ignore();
|
|
|
|
}
|
|
|
|
|
|
|
|
return QMainWindow::dragEnterEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainWindow::dropEvent(QDropEvent *event)
|
|
|
|
{
|
|
|
|
event->acceptProposedAction();
|
|
|
|
|
|
|
|
const QMimeData * mimeData = event->mimeData();
|
|
|
|
|
|
|
|
if (mimeData->hasUrls()) {
|
|
|
|
const QList<QUrl> &urls = mimeData->urls();
|
|
|
|
if (!urls.isEmpty()) {
|
|
|
|
m_filePath = urls.first().toLocalFile();
|
|
|
|
ui->label->setText(m_filePath);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-10-27 13:19:09 +08:00
|
|
|
|
|
|
|
void MainWindow::on_pushButton_clicked()
|
|
|
|
{
|
|
|
|
// 如果输出里有 psd 说明确实加载进去了
|
|
|
|
qDebug() << QImageReader::supportedImageFormats();
|
|
|
|
|
|
|
|
// 后面的文件改成 psd 文件的路径
|
2020-10-31 14:30:29 +08:00
|
|
|
QScopedPointer< QImageReader> ir(new QImageReader(m_filePath));
|
2020-10-27 13:19:09 +08:00
|
|
|
qDebug() << ir->canRead();
|
|
|
|
QImage read = ir->read();
|
|
|
|
if (read.isNull()) {
|
|
|
|
qDebug() << "read is null";
|
|
|
|
}
|
|
|
|
ui->label->setPixmap(QPixmap::fromImage(read));
|
|
|
|
}
|