Here's a shorter implementation. I'm still confused 
as to what is causing the artifact on the hex tiles.
Patch is against wesnoth 1.0.2.

-Jeff


diff -u /ramdisk/home/knoppix/bar/wesnoth-1.0.2/src/sdl_utils.cpp.orig 
/ramdisk/home/knoppix/bar/wesnoth-1.0.2/src/sdl_utils.cpp
--- /ramdisk/home/knoppix/bar/wesnoth-1.0.2/src/sdl_utils.cpp.orig      
2005-12-13 15:47:57.718864120 -0500
+++ /ramdisk/home/knoppix/bar/wesnoth-1.0.2/src/sdl_utils.cpp   2005-12-13 
17:46:17.261569576 -0500
@@ -155,12 +155,27 @@
 
                fixed_t ysrc = ftofxp(0.0);
                for(int ydst = 0; ydst != h; ++ydst, ysrc += yratio) {
                        fixed_t xsrc = ftofxp(0.0);
                        for(int xdst = 0; xdst != w; ++xdst, xsrc += xratio) {
                                const int xsrcint = fxptoi(xsrc);
                                const int ysrcint = fxptoi(ysrc);

-                               dst_pixels[ydst*dst->w + xdst] = 
src_pixels[ysrcint*src->w + xsrcint];
+                               Uint32* const src_word = src_pixels + 
ysrcint*src->w + xsrcint;
+                               Uint32* const dst_word = dst_pixels +    
ydst*dst->w + xdst;
+                               const int dx = (xsrcint + 1 < src->w) ? 
sizeof(Uint32) : 0;
+                               const int dy = (ysrcint + 1 < src->h) ? 
sizeof(Uint32) * src->w : 0;
+                               const fixed_t w = 0x000000FF & xsrc;
+                               const fixed_t s = 0x000000FF & ysrc;
+                               const fixed_t n = 0xFF - s;
+                               const fixed_t e = 0xFF - w;
+                               for (int byte=0; byte<4; byte++) {
+                                       Uint8* const dst_byte = 
(Uint8*)dst_word + byte;
+                                       Uint8* const src_byte = 
(Uint8*)src_word + byte;
+                                       Uint8* const ne = src_byte;
+                                       Uint8* const nw = src_byte + dx;
+                                       Uint8* const se = src_byte + dy;
+                                       Uint8* const sw = src_byte + dx + dy;
+                                       *dst_byte = (*ne*n*e + *nw*n*w + 
*sw*s*w + *se*s*e) >> 16;
+                               }
                        }
                }
        }

Reply via email to