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.
This commit is contained in:
Lukas Dürrenberger 2021-12-05 21:52:38 +01:00
parent 11020363b1
commit e53d9e88a9

View File

@ -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<int>(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<unsigned int>(srcPitch * static_cast<int>((m_size.y - 1)));
srcPitch = -srcPitch;
}
for (unsigned int i = 0; i < m_size.y; ++i)