mail[Wesnoth-commits] r20416 - /trunk/src/minimap.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by esr on September 16, 2007 - 00:10:
Author: esr
Date: Sun Sep 16 00:09:23 2007
New Revision: 20416

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20416&view=rev
Log:
When generating minimaps, preserve the aspect ratio of original maps
rather than distorting them to fit the minimap window.

Modified:
    trunk/src/minimap.cpp

Modified: trunk/src/minimap.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/minimap.cpp?rev=20416&r1=20415&r2=20416&view=diff
==============================================================================
--- trunk/src/minimap.cpp (original)
+++ trunk/src/minimap.cpp Sun Sep 16 00:09:23 2007
@@ -93,9 +93,16 @@
                }
        }
 
-       if((minimap->w != w || minimap->h != h) && w != 0) {
+       if((minimap->w != w || minimap->h != h) && w != 0 && h != 0) {
                const surface surf(minimap);
-               minimap = surface(scale_surface(surf,w,h));
+               float sw = 1.0, sh = 1.0;
+
+               // preserve the aspect ratio of the original map rather than
+               // distorting it to fit the minimap window.
+               if (minimap->h < minimap->w) sh = (minimap->h*1.0)/minimap->w;
+               if (minimap->w < minimap->h) sw = (minimap->w*1.0)/minimap->h;
+
+               minimap = surface(scale_surface(surf,int(w * sw),int(h * 
sh)));
        }
 
        LOG_DP << "done generating minimap\n";




Related Messages


Powered by MHonArc, Updated Sun Sep 16 00:20:12 2007