Stefan Dösinger : wined3d: Turn around the image in LockRect.

Alexandre Julliard julliard at wine.codeweavers.com
Thu May 25 04:15:54 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 40d3cc5ee4c2fb8606728da8a0681ba8702125a4
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=40d3cc5ee4c2fb8606728da8a0681ba8702125a4

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Wed May 24 17:37:43 2006 +0200

wined3d: Turn around the image in LockRect.

---

 dlls/wined3d/surface.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9fb52a8..ed9a549 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -588,12 +588,34 @@ #endif
             if ((This->lockedRect.left == 0 &&  This->lockedRect.top == 0 &&
                 This->lockedRect.right == This->currentDesc.Width
                 && This->lockedRect.bottom ==  This->currentDesc.Height)) {
+                    char *row, *top, *bottom;
+                    int i;
+
                     glReadPixels(0, 0,
                     This->currentDesc.Width,
                     This->currentDesc.Height,
                     This->glDescription.glFormat,
                     This->glDescription.glType,
                     (char *)pLockedRect->pBits);
+
+                    /* glReadPixels returns the image upside down, and there is no way to prevent this.
+                       Flip the lines in software*/
+                    row = HeapAlloc(GetProcessHeap(), 0, pLockedRect->Pitch);
+                    if(!row) {
+                        ERR("Out of memory\n");
+                        return E_OUTOFMEMORY;
+                    }
+                    top = This->resource.allocatedMemory;
+                    bottom = ( (char *) This->resource.allocatedMemory) + pLockedRect->Pitch * ( This->currentDesc.Height - 1);
+                    for(i = 0; i < This->currentDesc.Height / 2; i++) {
+                        memcpy(row, top, pLockedRect->Pitch);
+                        memcpy(top, bottom, pLockedRect->Pitch);
+                        memcpy(bottom, row, pLockedRect->Pitch);
+                        top += pLockedRect->Pitch;
+                        bottom -= pLockedRect->Pitch;
+                    }
+                    HeapFree(GetProcessHeap(), 0, row);
+
             } else if (This->lockedRect.left == 0 &&  This->lockedRect.right == This->currentDesc.Width) {
                     glReadPixels(0,
                     This->lockedRect.top,




More information about the wine-cvs mailing list