Skip to content

Commit

Permalink
image255x112 images that are too big are now silently resized
Browse files Browse the repository at this point in the history
  • Loading branch information
jg18 committed Jun 5, 2013
1 parent d44570c commit 58004f4
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions code/apis/SkinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,31 @@ bool Skin::SetModImage(const wxBitmap& modImage) {
if (!modImage.IsOk()) {
wxLogWarning(_T("Provided mod image is not valid."));
return false;
} else if ((modImage.GetWidth() != SkinSystem::ModInfoDialogImageWidth) ||
(modImage.GetHeight() != SkinSystem::ModInfoDialogImageHeight)) {
wxLogWarning(_T("Provided mod image size %dx%d is not expected size %dx%d."),
} else if ((modImage.GetWidth() > SkinSystem::ModInfoDialogImageWidth) ||
(modImage.GetHeight() > SkinSystem::ModInfoDialogImageHeight)) {
wxLogDebug(_T("Provided mod image size %dx%d is larger than expected size %dx%d. Resizing."),
modImage.GetWidth(), modImage.GetHeight(),
SkinSystem::ModInfoDialogImageWidth, SkinSystem::ModInfoDialogImageHeight);
return false;

wxImage tempModImage(modImage.ConvertToImage());
wxImage scaledTempModImage(
tempModImage.Scale(
SkinSystem::ModListImageWidth,
SkinSystem::ModListImageHeight,
wxIMAGE_QUALITY_HIGH));

wxBitmap newModImage(scaledTempModImage);
wxASSERT(newModImage.GetWidth() == SkinSystem::ModListImageWidth);
wxASSERT(newModImage.GetHeight() == SkinSystem::ModListImageHeight);

this->modImage = wxBitmap(newModImage);
return true;
} else if ((modImage.GetWidth() < SkinSystem::ModInfoDialogImageWidth) ||
(modImage.GetHeight() < SkinSystem::ModInfoDialogImageHeight)) {
wxLogDebug(_T("Provided mod image size %dx%d is smaller than expected size %dx%d. Using as is."),
modImage.GetWidth(), modImage.GetHeight(),
SkinSystem::ModInfoDialogImageWidth, SkinSystem::ModInfoDialogImageHeight);
return true;
} else {
this->modImage = modImage;
return true;
Expand Down

0 comments on commit 58004f4

Please sign in to comment.