mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-03-06 14:27:43 +00:00
(Windows) Converted forward slashes to backslashes for a few scraper debug log messages.
Also did some minor code cleanup.
This commit is contained in:
parent
9a9ac17aa3
commit
1fb8ce6b7d
|
@ -592,8 +592,8 @@ void MediaDownloadHandle::update()
|
||||||
|
|
||||||
bool resizeImage(const std::string& path, const std::string& mediaType)
|
bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
{
|
{
|
||||||
float maxWidth = 0.0f;
|
float maxWidth {0.0f};
|
||||||
float maxHeight = 0.0f;
|
float maxHeight {0.0f};
|
||||||
|
|
||||||
if (mediaType == "marquees") {
|
if (mediaType == "marquees") {
|
||||||
// We don't really need huge marquees.
|
// We don't really need huge marquees.
|
||||||
|
@ -605,8 +605,8 @@ bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
maxHeight = 1440.0f;
|
maxHeight = 1440.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
FREE_IMAGE_FORMAT format = FIF_UNKNOWN;
|
FREE_IMAGE_FORMAT format {FIF_UNKNOWN};
|
||||||
FIBITMAP* image = nullptr;
|
FIBITMAP* image {nullptr};
|
||||||
|
|
||||||
// Detect the file format.
|
// Detect the file format.
|
||||||
|
|
||||||
|
@ -637,19 +637,25 @@ bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float width = static_cast<float>(FreeImage_GetWidth(image));
|
float width {static_cast<float>(FreeImage_GetWidth(image))};
|
||||||
float height = static_cast<float>(FreeImage_GetHeight(image));
|
float height {static_cast<float>(FreeImage_GetHeight(image))};
|
||||||
|
|
||||||
// If the image is smaller than (or the same size as) maxWidth and maxHeight, then don't
|
// If the image is smaller than (or the same size as) maxWidth and maxHeight, then don't
|
||||||
// do any scaling. It doesn't make sense to upscale the image and waste disk space.
|
// do any scaling. It doesn't make sense to upscale the image and waste disk space.
|
||||||
if (maxWidth >= width && maxHeight >= height) {
|
if (maxWidth >= width && maxHeight >= height) {
|
||||||
|
#if defined(_WIN64)
|
||||||
|
LOG(LogDebug) << "Scraper::resizeImage(): Saving image \""
|
||||||
|
<< Utils::String::replace(path, "/", "\\") << "\" at its original resolution "
|
||||||
|
<< width << "x" << height;
|
||||||
|
#else
|
||||||
LOG(LogDebug) << "Scraper::resizeImage(): Saving image \"" << path
|
LOG(LogDebug) << "Scraper::resizeImage(): Saving image \"" << path
|
||||||
<< "\" at its original resolution " << width << "x" << height;
|
<< "\" at its original resolution " << width << "x" << height;
|
||||||
|
#endif
|
||||||
FreeImage_Unload(image);
|
FreeImage_Unload(image);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
float scaleFactor = 0.0f;
|
float scaleFactor {0.0f};
|
||||||
|
|
||||||
// Calculate how much we should scale.
|
// Calculate how much we should scale.
|
||||||
if (width > maxWidth) {
|
if (width > maxWidth) {
|
||||||
|
@ -665,8 +671,8 @@ bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
maxHeight = floorf(height * scaleFactor);
|
maxHeight = floorf(height * scaleFactor);
|
||||||
|
|
||||||
// We use Lanczos3 which is the highest quality resampling method available in FreeImage.
|
// We use Lanczos3 which is the highest quality resampling method available in FreeImage.
|
||||||
FIBITMAP* imageRescaled = FreeImage_Rescale(image, static_cast<int>(maxWidth),
|
FIBITMAP* imageRescaled {FreeImage_Rescale(image, static_cast<int>(maxWidth),
|
||||||
static_cast<int>(maxHeight), FILTER_LANCZOS3);
|
static_cast<int>(maxHeight), FILTER_LANCZOS3)};
|
||||||
FreeImage_Unload(image);
|
FreeImage_Unload(image);
|
||||||
|
|
||||||
if (imageRescaled == nullptr) {
|
if (imageRescaled == nullptr) {
|
||||||
|
@ -675,10 +681,10 @@ bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
bool saved = (FreeImage_SaveU(format, imageRescaled,
|
bool saved {FreeImage_SaveU(format, imageRescaled,
|
||||||
Utils::String::stringToWideString(path).c_str()) != 0);
|
Utils::String::stringToWideString(path).c_str()) != 0};
|
||||||
#else
|
#else
|
||||||
bool saved = (FreeImage_Save(format, imageRescaled, path.c_str()) != 0);
|
bool saved {FreeImage_Save(format, imageRescaled, path.c_str()) != 0};
|
||||||
#endif
|
#endif
|
||||||
FreeImage_Unload(imageRescaled);
|
FreeImage_Unload(imageRescaled);
|
||||||
|
|
||||||
|
@ -686,8 +692,14 @@ bool resizeImage(const std::string& path, const std::string& mediaType)
|
||||||
LOG(LogError) << "Failed to save resized image";
|
LOG(LogError) << "Failed to save resized image";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
#if defined(_WIN64)
|
||||||
|
LOG(LogDebug) << "Scraper::resizeImage(): Downscaled image \""
|
||||||
|
<< Utils::String::replace(path, "/", "\\") << "\" from " << width << "x"
|
||||||
|
<< height << " to " << maxWidth << "x" << maxHeight;
|
||||||
|
#else
|
||||||
LOG(LogDebug) << "Scraper::resizeImage(): Downscaled image \"" << path << "\" from "
|
LOG(LogDebug) << "Scraper::resizeImage(): Downscaled image \"" << path << "\" from "
|
||||||
<< width << "x" << height << " to " << maxWidth << "x" << maxHeight;
|
<< width << "x" << height << " to " << maxWidth << "x" << maxHeight;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return saved;
|
return saved;
|
||||||
|
|
Loading…
Reference in a new issue