vcl/opengl/salbmp.cxx |   36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)

New commits:
commit 8d924babf34ee9ef41e446cae4ea380fff68a57c
Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk>
Date:   Mon Oct 5 17:05:45 2015 +0200

    opengl: take row stride into account when reading to 1-bit bitmap
    
    Opengl doesn't support 1-bit bitmaps so we read back the texture
    as RGB bitmap and transform it to 1-bit bitmap. Previously the
    implementation did this but naively by converting the buffer without
    taking row strides into account. Now on row change the writing is
    reset into a new byte.
    
    (cherry picked from commit 11b2e2e8113b67b9c9c8d1076c07d22ac93ada72)
    
    Change-Id: Iaa67b209d5b6ab0d9c567a71dee0684a85f53f6b
    Reviewed-on: https://gerrit.libreoffice.org/19161
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Tested-by: Caolán McNamara <caol...@redhat.com>

diff --git a/vcl/opengl/salbmp.cxx b/vcl/opengl/salbmp.cxx
index 3ba62fa..cbf60c2 100644
--- a/vcl/opengl/salbmp.cxx
+++ b/vcl/opengl/salbmp.cxx
@@ -513,25 +513,31 @@ bool OpenGLSalBitmap::ReadTexture()
 
         sal_uInt8* pCurrent = pBuffer;
 
-        for (size_t i = 0; i < aBuffer.size(); i += 3)
+        for (int y = 0; y < mnHeight; ++y)
         {
-            sal_uInt8 nR = *pCurrent++;
-            sal_uInt8 nG = *pCurrent++;
-            sal_uInt8 nB = *pCurrent++;
-
-            if (nR > 0 && nG > 0 && nB > 0)
-            {
-                pData[nIndex] |= (1 << nShift);
-            }
-            nShift--;
-            if (nShift < 0)
+            for (int x = 0; x < mnWidth; ++x)
             {
-                nShift = 7;
-                nIndex++;
-                pData[nIndex] = 0;
+                if (nShift < 0)
+                {
+                    nShift = 7;
+                    nIndex++;
+                    pData[nIndex] = 0;
+                }
+
+                sal_uInt8 nR = *pCurrent++;
+                sal_uInt8 nG = *pCurrent++;
+                sal_uInt8 nB = *pCurrent++;
+
+                if (nR > 0 && nG > 0 && nB > 0)
+                {
+                    pData[nIndex] |= (1 << nShift);
+                }
+                nShift--;
             }
+            nShift = 7;
+            nIndex++;
+            pData[nIndex] = 0;
         }
-
         mnBufWidth = mnWidth;
         mnBufHeight = mnHeight;
         return true;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to