Skip to content

Commit faec29c

Browse files
committed
Fix stretched sprites. Closes #174
1 parent 50455cd commit faec29c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

source/graphics.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,8 @@ wxMemoryDC* GameSprite::getDC(SpriteSize size)
981981
if(!dc[size]) {
982982
ASSERT(width >= 1 && height >= 1);
983983

984-
wxImage image(width * SPRITE_PIXELS, height * SPRITE_PIXELS);
984+
uint8_t image_size = std::max<uint8_t>(width, height) * SPRITE_PIXELS;
985+
wxImage image(image_size, image_size);
985986

986987
for(uint8_t l = 0; l < layers; l++) {
987988
for(uint8_t w = 0; w < width; w++) {
@@ -1000,8 +1001,8 @@ wxMemoryDC* GameSprite::getDC(SpriteSize size)
10001001

10011002
// Now comes the resizing / antialiasing
10021003
if(size == SPRITE_SIZE_16x16 || image.GetWidth() > SPRITE_PIXELS || image.GetHeight() > SPRITE_PIXELS) {
1003-
int wh = SPRITE_SIZE_16x16 ? 16 : 32;
1004-
image.Rescale(wh, wh);
1004+
int new_size = SPRITE_SIZE_16x16 ? 16 : 32;
1005+
image.Rescale(new_size, new_size);
10051006
}
10061007

10071008
wxBitmap bmp(image);

0 commit comments

Comments
 (0)