From c5a98c282b86d97330352fe17a7b6998b38237e5 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Thu, 10 Dec 2015 00:02:59 +0100 Subject: SpriteCache: use correct pitch for sprite rotation --- src/view/SpriteCache.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/view') diff --git a/src/view/SpriteCache.cpp b/src/view/SpriteCache.cpp index 206aa1c..a7018f7 100644 --- a/src/view/SpriteCache.cpp +++ b/src/view/SpriteCache.cpp @@ -70,6 +70,8 @@ SpriteCache::sprite_value SpriteCache::load(const std::string &id, unsigned rota uint8_t *src = reinterpret_cast(base->pixels); uint8_t *dst = reinterpret_cast(surface->pixels); + int pitch = base->pitch; + int pitch2 = surface->pitch; for (int x = 0; x < w; x++) { for (int y = 0; y < h; y++) { @@ -89,7 +91,7 @@ SpriteCache::sprite_value SpriteCache::load(const std::string &id, unsigned rota y2 = x; } - std::memcpy(dst + d * (y2*w2 + x2), src + d * (y*w + x), d); + std::memcpy(dst + y2*pitch2 + d*x2, src + y*pitch + d*x, d); } } -- cgit v1.2.3