From e53d9e88a94e41adae42b2e5d52e060095226b47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Sun, 5 Dec 2021 21:52:38 +0100 Subject: [PATCH] Fix regression in copyToImage When the source image is flipped, we want to read the source data backwards and thus need to keep subtracting the "iterator" on the source data. --- src/SFML/Graphics/Texture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index f462f263..37837015 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -372,14 +372,14 @@ Image Texture::copyToImage() const // Then we copy the useful pixels from the temporary array to the final one const Uint8* src = &allPixels[0]; Uint8* dst = &pixels[0]; - unsigned int srcPitch = m_actualSize.x * 4; + int srcPitch = static_cast(m_actualSize.x * 4); unsigned int dstPitch = m_size.x * 4; // Handle the case where source pixels are flipped vertically if (m_pixelsFlipped) { - src += srcPitch * (m_size.y - 1); - srcPitch = UINT_MAX - srcPitch + 1; + src += static_cast(srcPitch * static_cast((m_size.y - 1))); + srcPitch = -srcPitch; } for (unsigned int i = 0; i < m_size.y; ++i)