We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3498

Summary: Flipping image with SW_RenderCopyEx causes corruption.
Product: SDL Reporter: Luke Jones <luke.nukem.jones>
Component: renderAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: major    
Priority: P2 CC: sylvain.becker
Version: 2.0.5   
Hardware: x86_64   
OS: Linux   

Description Luke Jones 2016-11-20 05:21:15 UTC
This is something of an edge case I think. I had just happened to be using the software renderer while writing up some examples using rust-sdl2.

Issue:
- Using a sprite sheet (bmp) for animation loops.

If a source and destination rectangle have the same coordinates and dimensions, and the image is being flipped, then the image glitches, looks as if it is a pointer somewhere accessing something it shouldn't be.

If as above but the image is not flipped, but is rotated, then the first frame starts in the middle of the sprite sheet.

Workaround:
Not ideal, but offsetting the first frame by 1 pixel solves both issues.
Or
- make destination 1 pixel larger in X and Y.
Or
- make source rect one pixel smaller in X and Y.
Or
- switch renderer to non-software.


Unfortunately this isn't really my area of expertise, so I am unable to offer much in the way of solutions, or dig much further in to it.

The issue was originally reported here - https://github.com/AngryLawyer/rust-sdl2/issues/492 - and I checked out all data/calls that rust-sdl2 makes just in case a reference was somehow being corrupted. Hopefully the source code in rust there should be of use (easy translation I think).
Comment 1 Sam Lantinga 2017-08-11 20:19:32 UTC
The software renderer flipping and rotation was rewritten to fix this. Can you check to make sure it works for you?

http://www.libsdl.org/tmp/SDL-2.0.zip

Thanks!
Comment 2 Sylvain 2017-10-18 09:31:05 UTC
I tried with an older version of SDL2 to see the issue (866896c224fd, march 2016). 
This is now fixed in the current version.
Comment 3 Sam Lantinga 2017-10-18 13:50:04 UTC
Great, thanks!