Index: /trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h	(revision 50370)
+++ /trunk/src/VBox/GuestHost/OpenGL/include/cr_vreg.h	(revision 50371)
@@ -49,10 +49,12 @@
 
 #ifndef IN_RING0
+#define CR_FLOAT_RCAST(_t, _v) ((_t)((float)(_v) + 0.5))
+
 DECLINLINE(void) VBoxRectStretch(PRTRECT pRect, float xStretch, float yStretch)
 {
-    pRect->xLeft = (int32_t)(pRect->xLeft * xStretch);
-    pRect->yTop = (int32_t)(pRect->yTop * yStretch);
-    pRect->xRight = (int32_t)(pRect->xRight * xStretch);
-    pRect->yBottom = (int32_t)(pRect->yBottom * yStretch);
+    pRect->xLeft = CR_FLOAT_RCAST(int32_t, pRect->xLeft * xStretch);
+    pRect->yTop = CR_FLOAT_RCAST(int32_t, pRect->yTop * yStretch);
+    pRect->xRight = CR_FLOAT_RCAST(int32_t, pRect->xRight * xStretch);
+    pRect->yBottom = CR_FLOAT_RCAST(int32_t, pRect->yBottom * yStretch);
 }
 
Index: /trunk/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp
===================================================================
--- /trunk/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp	(revision 50370)
+++ /trunk/src/VBox/GuestHost/OpenGL/util/bmpscale.cpp	(revision 50371)
@@ -61,7 +61,7 @@
 }
 
-DECLINLINE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color, int w)
+DECLINLINE(void) gdImageSetPixel (gdImagePtr im, int x, int y, int color, int cbLine)
 {
-    *(int32_t *)(im + y * w * 4 + x * 4) = color;
+    *(int32_t *)(im + y * cbLine + x * 4) = color;
 }
 
@@ -190,5 +190,5 @@
                gdTrueColorAlpha ((int) red,
                          (int) green,
-                         (int) blue, (int) alpha), dstW);
+                         (int) blue, (int) alpha), dstW * 4);
     }
     }
Index: /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp	(revision 50370)
+++ /trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_presenter.cpp	(revision 50371)
@@ -241,15 +241,13 @@
 }
 
-static void crFbBltImg(void *pvSrc, const RTRECT *pSrcDataRect, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, CR_BLITTER_IMG *pDst)
-{
-    int32_t cbSrcPitch = (pSrcDataRect->xRight - pSrcDataRect->xLeft) * 4;
-    int32_t srcX = pCopyRect->xLeft - pSrcDataRect->xLeft;
-    int32_t srcY = pCopyRect->yTop - pSrcDataRect->yTop;
+static void crFbBltImg(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, CR_BLITTER_IMG *pDst)
+{
+    int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x;
+    int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y;
     Assert(srcX >= 0);
     Assert(srcY >= 0);
-    Assert(srcX < pSrcDataRect->xRight - pSrcDataRect->xLeft);
-    Assert(srcY < pSrcDataRect->yBottom - pSrcDataRect->yTop);
-
-    uint32_t cbDstPitch = pDst->pitch;
+    Assert(srcX < pSrc->width);
+    Assert(srcY < pSrc->height);
+
     int32_t dstX = pCopyRect->xLeft - pDstDataPoint->x;
     int32_t dstY = pCopyRect->yTop - pDstDataPoint->y;
@@ -257,45 +255,52 @@
     Assert(dstY >= 0);
 
-    uint8_t *pu8Src = ((uint8_t*)pvSrc) + cbSrcPitch * (!fSrcInvert ? srcY : pSrcDataRect->yBottom - pSrcDataRect->yTop - srcY - 1) + srcX * 4;
-    uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + cbDstPitch * dstY + dstX * 4;
-    if (fSrcInvert)
-        cbSrcPitch = -cbSrcPitch;
-
-    crFbBltMem(pu8Src, cbSrcPitch, pu8Dst, cbDstPitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
-}
-
-static void crFbBltImgStretched(void *pvSrc, const RTRECT *pSrcDataRect, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
-{
-    int32_t cbSrcPitch = (pSrcDataRect->xRight - pSrcDataRect->xLeft) * 4;
-    int32_t srcX = pCopyRect->xLeft - pSrcDataRect->xLeft;
-    int32_t srcY = pCopyRect->yTop - pSrcDataRect->yTop;
+    uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4;
+    uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4;
+
+    crFbBltMem(pu8Src, fSrcInvert ? -pSrc->pitch : pSrc->pitch, pu8Dst, pDst->pitch, pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
+}
+
+static void crFbBltImgStretched(const CR_BLITTER_IMG *pSrc, const RTPOINT *pSrcDataPoint, bool fSrcInvert, const RTRECT *pCopyRect, const RTPOINT *pDstDataPoint, float strX, float strY, CR_BLITTER_IMG *pDst)
+{
+    int32_t srcX = pCopyRect->xLeft - pSrcDataPoint->x;
+    int32_t srcY = pCopyRect->yTop - pSrcDataPoint->y;
     Assert(srcX >= 0);
     Assert(srcY >= 0);
-    Assert(srcX < pSrcDataRect->xRight - pSrcDataRect->xLeft);
-    Assert(srcY < pSrcDataRect->yBottom - pSrcDataRect->yTop);
-
-    int32_t cbDstPitch = (int32_t)pDst->pitch;
-    int32_t dstX = static_cast<uint32_t>(strX * pCopyRect->xLeft - pDstDataPoint->x);
-    int32_t dstY = static_cast<uint32_t>(strY * pCopyRect->yTop - pDstDataPoint->y);
+    Assert(srcX < pSrc->width);
+    Assert(srcY < pSrc->height);
+
+    int32_t dstX = CR_FLOAT_RCAST(int32_t, strX * (pCopyRect->xLeft - pDstDataPoint->x));
+    int32_t dstY = CR_FLOAT_RCAST(int32_t, strY * (pCopyRect->yTop - pDstDataPoint->y));
     Assert(dstX >= 0);
     Assert(dstY >= 0);
 
-    uint8_t *pu8Src = ((uint8_t*)pvSrc) + cbSrcPitch * (!fSrcInvert ? srcY : pSrcDataRect->yBottom - pSrcDataRect->yTop - srcY - 1) + srcX * 4;
-    uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + cbDstPitch * dstY + dstX * 4;
-    if (fSrcInvert)
-        cbSrcPitch = -cbSrcPitch;
-
-    int srcW = pCopyRect->xRight - pCopyRect->xLeft;
-    int srcH = pCopyRect->yBottom - pCopyRect->yTop;
-    int dstW = static_cast<uint32_t>(strX * srcW);
-    int dstH = static_cast<uint32_t>(strY * srcH);
-
-    CrBmpScale32(pu8Dst, cbDstPitch,
-                            dstW, dstH,
-                            pu8Src,
-                            cbSrcPitch,
-                            srcW, srcH);
-}
-
+    uint8_t *pu8Src = ((uint8_t*)pSrc->pvData) + pSrc->pitch * (!fSrcInvert ? srcY : pSrc->height - srcY - 1) + srcX * 4;
+    uint8_t *pu8Dst = ((uint8_t*)pDst->pvData) + pDst->pitch * dstY + dstX * 4;
+
+    CrBmpScale32(pu8Dst, pDst->pitch,
+                        CR_FLOAT_RCAST(int32_t, strX * pCopyRect->xRight - pCopyRect->xLeft),
+                        CR_FLOAT_RCAST(int32_t, strY * pCopyRect->yBottom - pCopyRect->yTop),
+                        pu8Src,
+                        fSrcInvert ? -pSrc->pitch : pSrc->pitch,
+                        pCopyRect->xRight - pCopyRect->xLeft, pCopyRect->yBottom - pCopyRect->yTop);
+}
+
+static void crFbImgFromScreenVram(const VBVAINFOSCREEN *pScreen, void *pvVram, CR_BLITTER_IMG *pImg)
+{
+    pImg->pvData = pvVram;
+    pImg->cbData = pScreen->u32LineSize * pScreen->u32Height;
+    pImg->enmFormat = GL_BGRA;
+    pImg->width = pScreen->u32Width;
+    pImg->height = pScreen->u32Height;
+    pImg->bpp = pScreen->u16BitsPerPixel;
+    pImg->pitch = pScreen->u32LineSize;
+}
+
+static void crFbImgFromFb(HCR_FRAMEBUFFER hFb, CR_BLITTER_IMG *pImg)
+{
+    const VBVAINFOSCREEN *pScreen = CrFbGetScreenInfo(hFb);
+    void *pvVram = CrFbGetVRAM(hFb);
+    crFbImgFromScreenVram(pScreen, pvVram, pImg);
+}
 
 static int crFbBltGetContentsDirect(HCR_FRAMEBUFFER hFb, const RTRECT *pSrcRect, uint32_t cRects, const RTRECT *pRects, CR_BLITTER_IMG *pImg)
@@ -311,4 +316,10 @@
     float strY = ((float)pImg->height) / (pSrcRect->yBottom - pSrcRect->yTop);
 
+    RTPOINT StretchedSrcPoint;
+    StretchedSrcPoint.x = CR_FLOAT_RCAST(int32_t, strX * SrcPoint.x);
+    StretchedSrcPoint.y = CR_FLOAT_RCAST(int32_t, strY * SrcPoint.y);
+
+    RTPOINT ZeroPoint = {0, 0};
+
     VBoxVrListInit(&List);
     int rc = VBoxVrListRectsAdd(&List, 1, CrVrScrCompositorRectGet(&hFb->Compositor), NULL);
@@ -342,5 +353,5 @@
 
         uint32_t width, height;
-        RTRECT SrcRect;
+        RTPOINT StretchedEntryPoint;
 
         for (uint32_t i = 0; i < cRects; ++i)
@@ -409,7 +420,8 @@
                     const VBOXVR_TEXTURE *pVrTex = CrTdTexGet(pTex);
 
-                    width = static_cast<uint32_t>(strX * pVrTex->width);
-                    height = static_cast<uint32_t>(strY * pVrTex->height);
-                    VBoxRectStretched(CrVrScrCompositorEntryRectGet(pEntry), strX, strY, &SrcRect);
+                    width = CR_FLOAT_RCAST(uint32_t, strX * pVrTex->width);
+                    height = CR_FLOAT_RCAST(uint32_t, strY * pVrTex->height);
+                    StretchedEntryPoint.x = CR_FLOAT_RCAST(int32_t, strX * CrVrScrCompositorEntryRectGet(pEntry)->xLeft);
+                    StretchedEntryPoint.y = CR_FLOAT_RCAST(int32_t, strY * CrVrScrCompositorEntryRectGet(pEntry)->yTop);
                 }
 
@@ -423,5 +435,5 @@
                 bool fInvert = !(CrVrScrCompositorEntryFlagsGet(pEntry) & CRBLT_F_INVERT_SRC_YCOORDS);
 
-                crFbBltImg(pSrcImg->pvData, &SrcRect, fInvert, &Intersection, &SrcPoint, pImg);
+                crFbBltImg(pSrcImg, &StretchedEntryPoint, fInvert, &Intersection, &StretchedSrcPoint, pImg);
 
                 CrTdBltDataReleaseStretched(pTex, pSrcImg);
@@ -460,11 +472,16 @@
         RTPOINT Pos = {0};
         const RTRECT *pCompRect = CrVrScrCompositorRectGet(&hFb->Compositor);
-        uint32_t fbPitch = (pCompRect->xRight - pCompRect->xLeft) * 4;
+
+        uint32_t fbWidth = (pCompRect->xRight - pCompRect->xLeft);
         uint32_t fbHeight = pCompRect->yBottom - pCompRect->yTop;
 
-        uint32_t dstPitch = static_cast<uint32_t>(strX * fbPitch);
-        uint32_t dstHeight = static_cast<uint32_t>(strY * fbHeight);
-
-        bool fStretch = fbPitch != dstPitch || fbHeight != dstHeight;
+        uint32_t stretchedWidth = CR_FLOAT_RCAST(uint32_t, strX * fbWidth);
+        uint32_t stretchedHeight = CR_FLOAT_RCAST(uint32_t, strY * fbHeight);
+
+        CR_BLITTER_IMG FbImg;
+
+        bool fStretch = fbWidth != stretchedWidth || fbHeight != stretchedHeight;
+
+        crFbImgFromFb(hFb, &FbImg);
 
         for (uint32_t i = 0; i < cRects; ++i)
@@ -480,7 +497,7 @@
 
                 if (!fStretch)
-                    crFbBltImg(hFb->pvVram, pCompRect, false, &Intersection, &SrcPoint, pImg);
+                    crFbBltImg(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, pImg);
                 else
-                    crFbBltImgStretched(hFb->pvVram, pCompRect, false, &Intersection, &SrcPoint, strX, strY, pImg);
+                    crFbBltImgStretched(&FbImg, &ZeroPoint, false, &Intersection, &SrcPoint, strX, strY, pImg);
             }
         }
@@ -4427,11 +4444,5 @@
                 Rect.yBottom = Rect.yTop + pScreen->u32Height;
                 CR_BLITTER_IMG Img;
-                Img.pvData = pu8Buf;
-                Img.cbData = pScreen->u32LineSize * pScreen->u32Height;
-                Img.enmFormat = GL_BGRA;
-                Img.width = pScreen->u32Width;
-                Img.height = pScreen->u32Height;
-                Img.bpp = pScreen->u16BitsPerPixel;
-                Img.pitch = pScreen->u32LineSize;
+                crFbImgFromScreenVram(pScreen, pu8Buf, &Img);
                 int rc = CrFbBltGetContents(hFb, &Rect, cRects, pRects, &Img);
                 if (!RT_SUCCESS(rc))
