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:
parent
0b1b6007c6
commit
9fdb6822f6
|
@ -5,13 +5,14 @@ TextureCrafter::TextureCrafter(QObject *parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void TextureCrafter::packChannels(QVector<QUrl> imagePaths) {
|
void TextureCrafter::packChannels(QVector<QUrl> imagePaths) {
|
||||||
|
|
||||||
QVector<QImage> sourceImages;
|
QVector<QImage> sourceImages;
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
QImage::Format format = QImage::Format_RGB888;
|
QImage::Format format = QImage::Format_RGB888;
|
||||||
|
|
||||||
for (int i = 0; i < imagePaths.length(); i++) {
|
for (int i = 0; i < imagePaths.length(); i++) {
|
||||||
// if the ui layer did its job this will always be a file:// url
|
// 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
|
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
|
// 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();
|
QString outFileName = outDir.path();
|
||||||
outFileName.append("/out.png");
|
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 {
|
} else {
|
||||||
// chat its so over
|
//TODO: return some error value to show the user
|
||||||
|
printf("that dream is fucked it is fucking fucked\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
printf("chat its so over\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//do we need to close these??? idk lets hope qt handles it
|
//do we need to close these??? idk lets hope qt handles it
|
||||||
|
|
Loading…
Reference in a new issue