SpriteCache: use correct pitch for sprite rotation

This commit is contained in:
Matthias Schiffer 2015-12-10 00:02:59 +01:00
parent cc6a8f553e
commit c5a98c282b

View file

@ -70,6 +70,8 @@ SpriteCache::sprite_value SpriteCache::load(const std::string &id, unsigned rota
uint8_t *src = reinterpret_cast<uint8_t *>(base->pixels);
uint8_t *dst = reinterpret_cast<uint8_t *>(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);
}
}