Resample thumbnails to fix JPEG shear distortion if(width % 4 != 0)

This commit is contained in:
michaelrgb
2017-10-23 13:39:19 +01:00
committed by baldurk
parent 9b56227e50
commit 078efb8915
+5 -3
View File
@@ -2975,15 +2975,17 @@ WrappedOpenGL::BackbufferImage *WrappedOpenGL::SaveBackbufferImage()
m_Real.glPixelStorei(eGL_PACK_ALIGNMENT, prevPackAlignment);
// scale down if necessary using simple point sampling
if(thwidth > maxSize)
uint32_t resample_width = RDCMIN(maxSize, thwidth);
resample_width &= ~3; // JPEG encoder gives shear distortion if width is not divisible by 4.
if(thwidth != resample_width)
{
float widthf = float(thwidth);
float heightf = float(thheight);
float aspect = widthf / heightf;
// clamp dimensions to a width of maxSize
thwidth = maxSize;
// clamp dimensions to a width of resample_width
thwidth = resample_width;
thheight = uint32_t(float(thwidth) / aspect);
byte *src = thpixels;