git repos / sago_multi_scrambler_puzzle2

commit ed185a29

Poul Sander · 2024-01-20 11:12
ed185a294280100c3a7df85ca8109e09e4dcf8f4 patch · browse files
parent 7afb219423202b8aefe52ac3f6421e9f53385804

Now centers the thumpnails.

Changed files

M src/ImageHolder.cpp before
diff --git a/src/ImageHolder.cpp b/src/ImageHolder.cpp index dd8d16e..499718b 100644 --- a/src/ImageHolder.cpp +++ b/src/ImageHolder.cpp
@@ -83,6 +83,8 @@ void ImageHolder::Draw(SDL_Renderer* target, int x, int y, int max_w, int max_h)
printf("ImageHolder::Draw() called with no image loaded. Filename: %s\n", source_filename.c_str());
return;
}
+ int dest_w = max_w;
+ int dest_h = max_h;
int imgWidth = GetWidth();
int imgHeight = GetHeight();
@@ -103,6 +105,9 @@ void ImageHolder::Draw(SDL_Renderer* target, int x, int y, int max_w, int max_h)
max_w = static_cast<int>(max_h * aspect_ratio);
}
+ x = x + (dest_w - max_w) / 2;
+ y = y + (dest_h - max_h) / 2;
+
SDL_Rect destRect = { x, y, max_w, max_h };
SDL_RenderCopy(target, pictureTex, nullptr, &destRect);
}