From 078efb8915185acb7c409f9bf16c54b75b354e86 Mon Sep 17 00:00:00 2001 From: michaelrgb Date: Wed, 11 Oct 2017 14:17:40 +0100 Subject: [PATCH] Resample thumbnails to fix JPEG shear distortion if(width % 4 != 0) --- renderdoc/driver/gl/gl_driver.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index 1d625ed76..265e7c514 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -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;