Fix writing output file on Windows

Need to use QUrl::toLocalFile() instead of QUrl::path() to get the
actual file path
This commit is contained in:
Epicalert 2024-09-10 22:11:13 +08:00
parent 0b1b6007c6
commit 9fdb6822f6

View file

@ -5,13 +5,14 @@ TextureCrafter::TextureCrafter(QObject *parent)
{}
void TextureCrafter::packChannels(QVector<QUrl> imagePaths) {
QVector<QImage> 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<QUrl> 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