mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 05:58:35 +02:00
Merge pull request #13418 from zfox23/MS16052_PNG50
Implement MS16052: Use quality '50' when saving PNG Snapshots
This commit is contained in:
commit
1ea3b85a5d
1 changed files with 11 additions and 5 deletions
|
@ -365,15 +365,23 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot,
|
||||||
// DON'T append ".jpg" to the filename. QT will save the image in the format associated with the
|
// DON'T append ".jpg" to the filename. QT will save the image in the format associated with the
|
||||||
// filename's suffix.
|
// filename's suffix.
|
||||||
// If you want lossless Snapshots, supply a `.png` filename. Otherwise, use `.jpeg` or `.jpg`.
|
// If you want lossless Snapshots, supply a `.png` filename. Otherwise, use `.jpeg` or `.jpg`.
|
||||||
|
// For PNGs, we use a "quality" of "50". The output image quality is the same as "100"
|
||||||
|
// is the same as "0" -- the difference lies in the amount of compression applied to the PNG,
|
||||||
|
// which slightly affects the time it takes to save the image.
|
||||||
// Otherwise, ".jpg" is appended to the user's requested filename so that the image is saved in JPG format.
|
// Otherwise, ".jpg" is appended to the user's requested filename so that the image is saved in JPG format.
|
||||||
// If the user hasn't supplied a specific filename for the snapshot:
|
// If the user hasn't supplied a specific filename for the snapshot:
|
||||||
// Save the snapshot in JPG format according to FILENAME_PATH_FORMAT
|
// Save the snapshot in JPG format at "100" quality according to FILENAME_PATH_FORMAT
|
||||||
|
int imageQuality = 100;
|
||||||
QString filename;
|
QString filename;
|
||||||
if (!userSelectedFilename.isNull()) {
|
if (!userSelectedFilename.isNull()) {
|
||||||
QFileInfo snapshotFileInfo(userSelectedFilename);
|
QFileInfo snapshotFileInfo(userSelectedFilename);
|
||||||
QString userSelectedFilenameSuffix = snapshotFileInfo.suffix();
|
QString userSelectedFilenameSuffix = snapshotFileInfo.suffix();
|
||||||
|
userSelectedFilenameSuffix = userSelectedFilenameSuffix.toLower();
|
||||||
if (SUPPORTED_IMAGE_FORMATS.contains(userSelectedFilenameSuffix)) {
|
if (SUPPORTED_IMAGE_FORMATS.contains(userSelectedFilenameSuffix)) {
|
||||||
filename = userSelectedFilename;
|
filename = userSelectedFilename;
|
||||||
|
if (userSelectedFilenameSuffix == "png") {
|
||||||
|
imageQuality = 50;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
filename = userSelectedFilename + ".jpg";
|
filename = userSelectedFilename + ".jpg";
|
||||||
}
|
}
|
||||||
|
@ -381,8 +389,6 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot,
|
||||||
filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT));
|
filename = FILENAME_PATH_FORMAT.arg(username, now.toString(DATETIME_FORMAT));
|
||||||
}
|
}
|
||||||
|
|
||||||
const int IMAGE_QUALITY = 100;
|
|
||||||
|
|
||||||
if (!isTemporary) {
|
if (!isTemporary) {
|
||||||
// If user has requested specific path then use it, else use the application value
|
// If user has requested specific path then use it, else use the application value
|
||||||
QString snapshotFullPath;
|
QString snapshotFullPath;
|
||||||
|
@ -432,7 +438,7 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot,
|
||||||
imageFile = new QFile(snapshotFullPath);
|
imageFile = new QFile(snapshotFullPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
shot.save(imageFile, 0, IMAGE_QUALITY);
|
shot.save(imageFile, 0, imageQuality);
|
||||||
imageFile->close();
|
imageFile->close();
|
||||||
|
|
||||||
return imageFile;
|
return imageFile;
|
||||||
|
@ -447,7 +453,7 @@ QFile* Snapshot::savedFileForSnapshot(QImage& shot,
|
||||||
}
|
}
|
||||||
imageTempFile->setAutoRemove(isTemporary);
|
imageTempFile->setAutoRemove(isTemporary);
|
||||||
|
|
||||||
shot.save(imageTempFile, 0, IMAGE_QUALITY);
|
shot.save(imageTempFile, 0, imageQuality);
|
||||||
imageTempFile->close();
|
imageTempFile->close();
|
||||||
|
|
||||||
return imageTempFile;
|
return imageTempFile;
|
||||||
|
|
Loading…
Reference in a new issue