I found a relatively simple fix... (of course, it may cause some other problem, but I don't see it offhand).
In the blitStretch function, where it calculates the ratios rx and ry, if you change the calculation to use signed ints instead of unsigned, it works.
Change
- Code:
unsigned rx = unsigned(srcRect.GetWidth() << 10) / unsigned(destRect.GetWidth());
unsigned ry = unsigned(srcRect.GetHeight() << 10) / unsigned(destRect.GetHeight());
TO
- Code:
unsigned rx = int(srcRect.GetWidth() << 10) / int(destRect.GetWidth());
unsigned ry = int(srcRect.GetHeight() << 10) / int(destRect.GetHeight());
Note: don't change rx and ry to signed, just the calculation...
Leave everything else alone.
Now, to flip horizontally, use
- Code:
Rect src( bitmap->GetWidth(), 0, 0, bitmap->GetHeight() );
display->BlitStretch(dest, bitmap, &src);
The same goes for vertical or both, just swap the left/right or top/bottom numbers in the source rect.
This is obviously going to be slower than modifying the ->Blit() code (since that uses mem copies), but it's almost like it was indended to be that way with respect to the blitStretch.