From 9fdb6822f6c3140399c99cdc41a67a07f07ab247 Mon Sep 17 00:00:00 2001 From: Epicalert Date: Tue, 10 Sep 2024 22:11:13 +0800 Subject: [PATCH] Fix writing output file on Windows Need to use QUrl::toLocalFile() instead of QUrl::path() to get the actual file path --- texturecrafter.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/texturecrafter.cpp b/texturecrafter.cpp index 5665c83..67044a8 100644 --- a/texturecrafter.cpp +++ b/texturecrafter.cpp @@ -5,13 +5,14 @@ TextureCrafter::TextureCrafter(QObject *parent) {} void TextureCrafter::packChannels(QVector imagePaths) { + QVector sourceImages; int width = 0, height = 0; QImage::Format format = QImage::Format_RGB888; for (int i = 0; i < imagePaths.length(); i++) { // if the ui layer did its job this will always be a file:// url - QString rawPath = imagePaths[i].path(); + QString rawPath = imagePaths[i].toLocalFile(); QImage newImage(rawPath); // would this cause a use after free idk // we just use the first image's dimensions and force the others to conform hehe @@ -49,9 +50,17 @@ void TextureCrafter::packChannels(QVector imagePaths) { QString outFileName = outDir.path(); outFileName.append("/out.png"); - outImage.save(outFileName); + printf("wrote to %s\n", outFileName.toLatin1().data()); + + //TODO: use libpng and do progressive write to update the progress bar + if (outImage.save(outFileName)) { + printf("cool ^-^\n"); + } else { + //TODO: return some error value to show the user + printf("that dream is fucked it is fucking fucked\n"); + } } else { - // chat its so over + printf("chat its so over\n"); } //do we need to close these??? idk lets hope qt handles it