Update app/ddsviewer.h
This commit is contained in:
parent
4db49c0896
commit
d166e3329a
@ -1,98 +1,98 @@
|
|||||||
#include "iwiviewer.h"
|
#include "iwiviewer.h"
|
||||||
#include "enums.h"
|
#include "enums.h"
|
||||||
#include "ui_iwiviewer.h"
|
#include "ui_iwiviewer.h"
|
||||||
|
|
||||||
IWIViewer::IWIViewer(QWidget *parent)
|
IWIViewer::IWIViewer(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, ui(new Ui::IWIViewer)
|
, ui(new Ui::IWIViewer)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
IWIViewer::~IWIViewer()
|
IWIViewer::~IWIViewer()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWIViewer::SetIWIFile(std::shared_ptr<IWIFile> aIWIFile) {
|
void IWIViewer::SetIWIFile(const IWIFile* aIWIFile) {
|
||||||
mIWIFile.swap(aIWIFile);
|
mIWIFile = aIWIFile;
|
||||||
|
|
||||||
ui->label_Title->setText(mIWIFile->fileStem + ".iwi");
|
ui->label_Title->setText(mIWIFile->fileStem + ".iwi");
|
||||||
|
|
||||||
// If you’re using Qt and want a QString:
|
// If you’re using Qt and want a QString:
|
||||||
QString magicStr = QString::fromLatin1(mIWIFile->header.Magic, 3);
|
QString magicStr = QString::fromLatin1(mIWIFile->header.Magic, 3);
|
||||||
ui->lineEdit_Magic->setText(magicStr);
|
ui->lineEdit_Magic->setText(magicStr);
|
||||||
|
|
||||||
ui->spinBox_Version->setValue(mIWIFile->header.Version);
|
ui->spinBox_Version->setValue(mIWIFile->header.Version);
|
||||||
ui->spinBox_Depth->setValue(mIWIFile->info.Depth);
|
ui->spinBox_Depth->setValue(mIWIFile->info.Depth);
|
||||||
QString formatStr = "";
|
QString formatStr = "";
|
||||||
switch (mIWIFile->info.Format) {
|
switch (mIWIFile->info.Format) {
|
||||||
case IWI_FORMAT_ARGB32:
|
case IWI_FORMAT_ARGB32:
|
||||||
formatStr = "ARGB32";
|
formatStr = "ARGB32";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_RGB24:
|
case IWI_FORMAT_RGB24:
|
||||||
formatStr = "RGB24";
|
formatStr = "RGB24";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_GA16:
|
case IWI_FORMAT_GA16:
|
||||||
formatStr = "GA16";
|
formatStr = "GA16";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_A8:
|
case IWI_FORMAT_A8:
|
||||||
formatStr = "A8";
|
formatStr = "A8";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_DXT1:
|
case IWI_FORMAT_DXT1:
|
||||||
formatStr = "DXT1";
|
formatStr = "DXT1";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_DXT3:
|
case IWI_FORMAT_DXT3:
|
||||||
formatStr = "DXT3";
|
formatStr = "DXT3";
|
||||||
break;
|
break;
|
||||||
case IWI_FORMAT_DXT5:
|
case IWI_FORMAT_DXT5:
|
||||||
formatStr = "DXT5";
|
formatStr = "DXT5";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ui->lineEdit_Format->setText(formatStr);
|
ui->lineEdit_Format->setText(formatStr);
|
||||||
ui->spinBox_Height->setValue(mIWIFile->info.Height);
|
ui->spinBox_Height->setValue(mIWIFile->info.Height);
|
||||||
ui->spinBox_Width->setValue(mIWIFile->info.Width);
|
ui->spinBox_Width->setValue(mIWIFile->info.Width);
|
||||||
ui->spinBox_Usage->setValue(mIWIFile->info.Usage);
|
ui->spinBox_Usage->setValue(mIWIFile->info.Usage);
|
||||||
|
|
||||||
ui->comboBox_Mipmap->clear();
|
ui->comboBox_Mipmap->clear();
|
||||||
for (auto mipmap : mIWIFile->mipmaps) {
|
for (auto mipmap : mIWIFile->mipmaps) {
|
||||||
ui->comboBox_Mipmap->addItem(QString::number(mipmap.offset));
|
ui->comboBox_Mipmap->addItem(QString::number(mipmap.offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(ui->comboBox_Mipmap, &QComboBox::currentIndexChanged, this, &IWIViewer::MipmapIndexChanged);
|
connect(ui->comboBox_Mipmap, &QComboBox::currentIndexChanged, this, &IWIViewer::MipmapIndexChanged);
|
||||||
|
|
||||||
if (!mIWIFile->mipmaps.empty()) {
|
if (!mIWIFile->mipmaps.empty()) {
|
||||||
MipmapIndexChanged(0);
|
MipmapIndexChanged(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IWIViewer::MipmapIndexChanged(int aMipmapIndex) {
|
void IWIViewer::MipmapIndexChanged(int aMipmapIndex) {
|
||||||
auto mipmaps = mIWIFile->mipmaps;
|
auto mipmaps = mIWIFile->mipmaps;
|
||||||
|
|
||||||
if (aMipmapIndex == -1) { return; }
|
if (aMipmapIndex == -1) { return; }
|
||||||
|
|
||||||
auto mipmap = mipmaps[aMipmapIndex];
|
auto mipmap = mipmaps[aMipmapIndex];
|
||||||
ui->spinBox_MipmapSize->setValue(mipmap.size);
|
ui->spinBox_MipmapSize->setValue(mipmap.size);
|
||||||
ui->spinBox_MipmapOffset->setValue(mipmap.offset);
|
ui->spinBox_MipmapOffset->setValue(mipmap.offset);
|
||||||
|
|
||||||
const unsigned char* imageData = reinterpret_cast<const unsigned char*>(mipmap.data.constData());
|
const unsigned char* imageData = reinterpret_cast<const unsigned char*>(mipmap.data.constData());
|
||||||
QImage image(reinterpret_cast<const uchar*>(imageData),
|
QImage image(reinterpret_cast<const uchar*>(imageData),
|
||||||
mIWIFile->info.Width, mIWIFile->info.Height,
|
mIWIFile->info.Width, mIWIFile->info.Height,
|
||||||
QImage::Format_RGBA8888);
|
QImage::Format_RGBA8888);
|
||||||
|
|
||||||
if (image.isNull()) {
|
if (image.isNull()) {
|
||||||
qDebug() << "Error: QImage creation failed!";
|
qDebug() << "Error: QImage creation failed!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert to QPixmap
|
// Convert to QPixmap
|
||||||
QPixmap pixmap = QPixmap::fromImage(image);
|
QPixmap pixmap = QPixmap::fromImage(image);
|
||||||
if (pixmap.isNull()) {
|
if (pixmap.isNull()) {
|
||||||
qDebug() << "Error: QPixmap conversion failed!";
|
qDebug() << "Error: QPixmap conversion failed!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale and display
|
// Scale and display
|
||||||
pixmap = pixmap.scaled(ui->label_Image->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
pixmap = pixmap.scaled(ui->label_Image->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
ui->label_Image->setPixmap(pixmap);
|
ui->label_Image->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user