Index: /trunk/src/VBox/Main/DisplayImpl.cpp
===================================================================
--- /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 31278)
+++ /trunk/src/VBox/Main/DisplayImpl.cpp	(revision 31279)
@@ -181,17 +181,15 @@
         uint8_t *dst = pu8Thumbnail;
         uint8_t *src = pu8Data;
-        int dstX = 0;
-        int dstY = 0;
-        int srcX = 0;
-        int srcY = 0;
         int dstW = cxThumbnail;
         int dstH = cyThumbnail;
         int srcW = cx;
         int srcH = cy;
-        gdImageCopyResampled (dst,
-                              src,
-                              dstX, dstY,
-                              srcX, srcY,
-                              dstW, dstH, srcW, srcH);
+        int iDeltaLine = cx * 4;
+
+        BitmapScale32 (dst,
+                       dstW, dstH,
+                       src,
+                       iDeltaLine,
+                       srcW, srcH);
 
         *ppu8Thumbnail = pu8Thumbnail;
@@ -291,17 +289,15 @@
             uint8_t *dst = pu8Bitmap;
             uint8_t *src = pu8Data;
-            int dstX = 0;
-            int dstY = 0;
-            int srcX = 0;
-            int srcY = 0;
             int dstW = cxBitmap;
             int dstH = cyBitmap;
             int srcW = cx;
             int srcH = cy;
-            gdImageCopyResampled (dst,
-                                  src,
-                                  dstX, dstY,
-                                  srcX, srcY,
-                                  dstW, dstH, srcW, srcH);
+            int iDeltaLine = cx * 4;
+
+            BitmapScale32 (dst,
+                           dstW, dstH,
+                           src,
+                           iDeltaLine,
+                           srcW, srcH);
         }
         else
@@ -2469,17 +2465,15 @@
             uint8_t *dst = address;
             uint8_t *src = pu8Data;
-            int dstX = 0;
-            int dstY = 0;
-            int srcX = 0;
-            int srcY = 0;
             int dstW = width;
             int dstH = height;
             int srcW = cx;
             int srcH = cy;
-            gdImageCopyResampled (dst,
-                                  src,
-                                  dstX, dstY,
-                                  srcX, srcY,
-                                  dstW, dstH, srcW, srcH);
+            int iDeltaLine = cx * 4;
+
+            BitmapScale32 (dst,
+                           dstW, dstH,
+                           src,
+                           iDeltaLine,
+                           srcW, srcH);
         }
 
Index: /trunk/src/VBox/Main/DisplayResampleImage.cpp
===================================================================
--- /trunk/src/VBox/Main/DisplayResampleImage.cpp	(revision 31278)
+++ /trunk/src/VBox/Main/DisplayResampleImage.cpp	(revision 31279)
@@ -194,2 +194,124 @@
     }
 }
+
+/* Fast interger implementation for 32 bpp bitmap scaling.
+ * Use fixed point values * 16.
+ */
+typedef int32_t FIXEDPOINT;
+#define INT_TO_FIXEDPOINT(i) (FIXEDPOINT)((i) << 4)
+#define FIXEDPOINT_TO_INT(v) (int)((v) >> 4)
+#define FIXEDPOINT_FLOOR(v) ((v) & ~0xF)
+#define FIXEDPOINT_FRACTION(v) ((v) & 0xF)
+
+/* For 32 bit source only. */
+void BitmapScale32 (uint8_t *dst,
+                        int dstW, int dstH,
+                        const uint8_t *src,
+                        int iDeltaLine,
+                        int srcW, int srcH)
+{
+    int x, y;
+
+    for (y = 0; y < dstH; y++)
+    {
+        FIXEDPOINT sy1 = INT_TO_FIXEDPOINT(y * srcH) / dstH;
+        FIXEDPOINT sy2 = INT_TO_FIXEDPOINT((y + 1) * srcH) / dstH;
+
+        for (x = 0; x < dstW; x++)
+        {
+            FIXEDPOINT red = 0, green = 0, blue = 0;
+
+            FIXEDPOINT sx1 = INT_TO_FIXEDPOINT(x * srcW) / dstW;
+            FIXEDPOINT sx2 = INT_TO_FIXEDPOINT((x + 1) * srcW) / dstW;
+
+            FIXEDPOINT spixels = (sx2 - sx1) * (sy2 - sy1);
+
+            FIXEDPOINT sy = sy1;
+
+            do
+            {
+                FIXEDPOINT yportion;
+                if (FIXEDPOINT_FLOOR (sy) == FIXEDPOINT_FLOOR (sy1))
+                {
+                    yportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sy);
+                    if (yportion > sy2 - sy1)
+                    {
+                        yportion = sy2 - sy1;
+                    }
+                    sy = FIXEDPOINT_FLOOR (sy);
+                }
+                else if (sy == FIXEDPOINT_FLOOR (sy2))
+                {
+                    yportion = FIXEDPOINT_FRACTION(sy2);
+                }
+                else
+                {
+                    yportion = INT_TO_FIXEDPOINT(1);
+                }
+
+                const uint8_t *pu8SrcLine = src + iDeltaLine * FIXEDPOINT_TO_INT(sy);
+                FIXEDPOINT sx = sx1;
+                do
+                {
+                    FIXEDPOINT xportion;
+                    FIXEDPOINT pcontribution;
+                    int p;
+                    if (FIXEDPOINT_FLOOR (sx) == FIXEDPOINT_FLOOR (sx1))
+                    {
+                        xportion = INT_TO_FIXEDPOINT(1) - FIXEDPOINT_FRACTION(sx);
+                        if (xportion > sx2 - sx1)
+                        {
+                            xportion = sx2 - sx1;
+                        }
+                        pcontribution = xportion * yportion;
+                        sx = FIXEDPOINT_FLOOR (sx);
+                    }
+                    else if (sx == FIXEDPOINT_FLOOR (sx2))
+                    {
+                        xportion = FIXEDPOINT_FRACTION(sx2);
+                        pcontribution = xportion * yportion;
+                    }
+                    else
+                    {
+                        xportion = INT_TO_FIXEDPOINT(1);
+                        pcontribution = xportion * yportion;
+                    }
+                    /* Color depth specific code begin */
+                    p = *(uint32_t *)(pu8SrcLine + FIXEDPOINT_TO_INT(sx) * 4);
+                    /* Color depth specific code end */
+                    red += gdTrueColorGetRed (p) * pcontribution;
+                    green += gdTrueColorGetGreen (p) * pcontribution;
+                    blue += gdTrueColorGetBlue (p) * pcontribution;
+
+                    sx += INT_TO_FIXEDPOINT(1);
+                } while (sx < sx2);
+
+                sy += INT_TO_FIXEDPOINT(1);
+            } while (sy < sy2);
+
+            if (spixels != 0)
+            {
+                red /= spixels;
+                green /= spixels;
+                blue /= spixels;
+            }
+            /* Clamping to allow for rounding errors above */
+            if (red > 255)
+            {
+                red = 255;
+            }
+            if (green > 255)
+            {
+                green = 255;
+            }
+            if (blue > 255)
+            {
+                blue = 255;
+            }
+            gdImageSetPixel (dst,
+                             x, y,
+                             ( ((int) red) << 16) + (((int) green) << 8) + ((int) blue),
+                             dstW);
+        }
+    }
+}
Index: /trunk/src/VBox/Main/include/DisplayImpl.h
===================================================================
--- /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 31278)
+++ /trunk/src/VBox/Main/include/DisplayImpl.h	(revision 31279)
@@ -273,4 +273,10 @@
 
 
+void BitmapScale32 (uint8_t *dst,
+                        int dstW, int dstH,
+                        const uint8_t *src,
+                        int iDeltaLine,
+                        int srcW, int srcH);
+
 #endif // ____H_DISPLAYIMPL
 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
