aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/ROMInfoDialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/qt_sdl/ROMInfoDialog.cpp')
-rw-r--r--src/frontend/qt_sdl/ROMInfoDialog.cpp39
1 files changed, 33 insertions, 6 deletions
diff --git a/src/frontend/qt_sdl/ROMInfoDialog.cpp b/src/frontend/qt_sdl/ROMInfoDialog.cpp
index b381803..34917d0 100644
--- a/src/frontend/qt_sdl/ROMInfoDialog.cpp
+++ b/src/frontend/qt_sdl/ROMInfoDialog.cpp
@@ -21,6 +21,8 @@
#include <QFileDialog>
+#include "gif-h/gif.h"
+
#include "NDS.h"
#include "NDSCart.h"
#include "Platform.h"
@@ -45,23 +47,24 @@ ROMInfoDialog::ROMInfoDialog(QWidget* parent) : QDialog(parent), ui(new Ui::ROMI
const NDSBanner* banner = NDS::NDSCartSlot->GetCart()->Banner();
const NDSHeader& header = NDS::NDSCartSlot->GetCart()->GetHeader();
+
u32 iconData[32 * 32];
ROMManager::ROMIcon(banner->Icon, banner->Palette, iconData);
- iconImage = QImage(reinterpret_cast<unsigned char*>(iconData), 32, 32, QImage::Format_ARGB32).copy();
+ iconImage = QImage(reinterpret_cast<u8*>(iconData), 32, 32, QImage::Format_RGBA8888).copy();
ui->iconImage->setPixmap(QPixmap::fromImage(iconImage));
if (banner->Version == 0x103)
{
- u32 animatedIconData[32 * 32 * 64] = {0};
+ ui->saveAnimatedIconButton->setEnabled(true);
+
ROMManager::AnimatedROMIcon(banner->DSiIcon, banner->DSiPalette, banner->DSiSequence, animatedIconData, animatedSequence);
- for (int i = 0; i < 64; i++)
+ for (u32* image: animatedIconData)
{
- if (animatedIconData[32 * 32 * i] == 0)
+ if (!image)
break;
- animatedIconImages.push_back(QPixmap::fromImage(QImage(reinterpret_cast<unsigned char*>(&animatedIconData[32 * 32 * i]), 32, 32, QImage::Format_ARGB32).copy()));
+ animatedIconImages.push_back(QPixmap::fromImage(QImage(reinterpret_cast<u8*>(image), 32, 32, QImage::Format_RGBA8888).copy()));
}
-
iconTimeline = new QTimeLine(animatedSequence.size() / 60 * 1000, this);
iconTimeline->setFrameRange(0, animatedSequence.size() - 1);
iconTimeline->setLoopCount(0);
@@ -139,6 +142,30 @@ void ROMInfoDialog::on_saveIconButton_clicked()
iconImage.save(filename, "PNG");
}
+void ROMInfoDialog::on_saveAnimatedIconButton_clicked()
+{
+ QString filename = QFileDialog::getSaveFileName(this,
+ "Save Animated Icon",
+ QString::fromStdString(Config::LastROMFolder),
+ "GIF Images (*.gif)");
+ if (filename.isEmpty())
+ return;
+
+
+ GifWriter writer;
+
+ // The GIF format only supports delays of 0.01 seconds, so 0.0166... (60fps)
+ // is rounded up to 0.02 (50fps)
+ GifBegin(&writer, filename.toStdString().c_str(), 32, 32, 2);
+ for (int i: animatedSequence)
+ {
+ if (animatedIconData[i] == 0)
+ break;
+ GifWriteFrame(&writer, reinterpret_cast<u8*>(animatedIconData[i]), 32, 32, 2);
+ }
+ GifEnd(&writer);
+}
+
void ROMInfoDialog::iconSetFrame(int frame)
{
ui->dsiIconImage->setPixmap(animatedIconImages[animatedSequence[frame]]);