Better handle thumbnail generation of extreme aspect ratio images (fixes #3794)
* Backport fix taken from ART * Enforce minimal thumbnail size of 1x1 px in two places, prevents divison by zero and empty image generation
This commit is contained in:
@@ -106,8 +106,12 @@ void BatchQueueEntry::refreshThumbnailImage ()
|
||||
|
||||
void BatchQueueEntry::calcThumbnailSize ()
|
||||
{
|
||||
|
||||
prew = preh * origpw / origph;
|
||||
if (prew > options.maxThumbnailWidth) {
|
||||
const float s = static_cast<float>(options.maxThumbnailWidth) / prew;
|
||||
prew = options.maxThumbnailWidth;
|
||||
preh = std::max<int>(preh * s, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -261,9 +265,8 @@ void BatchQueueEntry::_updateImage (guint8* img, int w, int h)
|
||||
MYWRITERLOCK(l, lockRW);
|
||||
|
||||
prew = w;
|
||||
assert (preview == nullptr);
|
||||
preview = new guint8 [prew * preh * 3];
|
||||
memcpy (preview, img, prew * preh * 3);
|
||||
preview.resize(prew * preh * 3);
|
||||
std::copy(img, img + preview.size(), preview.begin());
|
||||
|
||||
if (parent) {
|
||||
parent->redrawNeeded (this);
|
||||
|
Reference in New Issue
Block a user