[Libreoffice-commits] core.git: include/vcl lotuswordpro/source svx/source vcl/source

Noel Grandin noel.grandin at collabora.co.uk
Thu Feb 15 17:35:13 UTC 2018


 include/vcl/BitmapTools.hxx                       |    2 +-
 lotuswordpro/source/filter/lwpbackgroundstuff.cxx |   10 +++++-----
 lotuswordpro/source/filter/lwpbackgroundstuff.hxx |    2 +-
 svx/source/sdr/primitive2d/sdrprimitivetools.cxx  |    2 +-
 vcl/source/bitmap/BitmapTools.cxx                 |   10 +++++-----
 5 files changed, 13 insertions(+), 13 deletions(-)

New commits:
commit 380da094b0ad765b80c353a6b6d2a1aa6a003f6a
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Feb 15 13:27:30 2018 +0200

    ofz#6372 fix bitmap decoding of pattern in LwpBackgroundStuff
    
    after
        commit b90e098a354323b635bab3ee8f9c79deb1e734fe
        use BitmapEx in LwpBackgroundStuff
    
    <caolan> maybe the lotuswordpro original stride is really 4 after all
    (as a common stride), with the first byte on each line containing the
    8bits for each row
    
    The original code in GetPattern() looked pretty dodgy since it was
    copying 32-bytes into an 8 byte buffer.
    Assume that the reversing part is right, and that the format is really a
    1bit packed 8x8 image.
    
    Also fix the decoding of such a image in CreateFromData to assume packed
    format, which is more predictable.
    
    Also fix the bug in createDefaultCross_3x3 which changing the assert
    revealed.
    
    Change-Id: I7196ae601429bbe0f842399df61c8b858e022d3e
    Reviewed-on: https://gerrit.libreoffice.org/49808
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/vcl/BitmapTools.hxx b/include/vcl/BitmapTools.hxx
index 4caafb3545e4..cf790e85be14 100644
--- a/include/vcl/BitmapTools.hxx
+++ b/include/vcl/BitmapTools.hxx
@@ -64,7 +64,7 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param pData
     The block of data to copy
     @param nStride
-    The number of bytes in a scanline, must >= width
+    The number of bytes in a scanline, must be >= (width * nBitCount / 8)
 */
 BitmapEx VCL_DLLPUBLIC CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount );
 
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
index 7ee17a64fdd8..6aecf25ddcaf 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -76,7 +76,7 @@ void LwpBackgroundStuff::Read(LwpObjectStream* pStrm)
     pStrm->SkipExtra();
 }
 
-void LwpBackgroundStuff::GetPattern(sal_uInt16 btPttnIndex, sal_uInt8* pPttnArray)
+void LwpBackgroundStuff::GetPattern(sal_uInt16 btPttnIndex, sal_uInt8 (&pPttnArray)[8])
 {
     if (btPttnIndex > 71)
     {
@@ -85,9 +85,9 @@ void LwpBackgroundStuff::GetPattern(sal_uInt16 btPttnIndex, sal_uInt8* pPttnArra
     }
     assert((2 < btPttnIndex) && (btPttnIndex < 72));
     const sal_uInt8* pTempArray = s_pLwpPatternTab[btPttnIndex];
-    for(sal_uInt8 i = 0; i < 32; i++)
+    for(sal_uInt8 i = 0; i < 8; i++)
     {
-        pPttnArray[i] = (i%4 == 0) ? pTempArray[7-i/4] : 0;
+        pPttnArray[i] = pTempArray[7-i];
     }
 }
 
@@ -110,11 +110,11 @@ XFBGImage* LwpBackgroundStuff::GetFillPattern()
     }
 
     // get pattern array from pattern table
-    sal_uInt8 aPttnArray[32];
+    sal_uInt8 aPttnArray[8];
     GetPattern(m_nID, aPttnArray);
 
     // create bitmap object from the pattern array
-    BitmapEx aBmp = vcl::bitmap::CreateFromData( aPttnArray, 8, 8, 8, 1 );
+    BitmapEx aBmp = vcl::bitmap::CreateFromData( aPttnArray, 8, 8, 1, 1 );
 
     // create XOBitmap object from bitmap object
     XOBitmap aXOBitmap( aBmp );
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.hxx b/lotuswordpro/source/filter/lwpbackgroundstuff.hxx
index 6f3ab8a1ca16..ee2c4af4d5ec 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.hxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.hxx
@@ -145,7 +145,7 @@ public:
     }
 
 private:
-    static void GetPattern(sal_uInt16 btPttnIndex, sal_uInt8* pPttnArray);
+    static void GetPattern(sal_uInt16 btPttnIndex, sal_uInt8 (&pPttnArray)[8]);
 
 public:
     void    Read(LwpObjectStream *pStrm);
diff --git a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
index 6b8a61ea4b01..8eecbeee0715 100644
--- a/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
+++ b/svx/source/sdr/primitive2d/sdrprimitivetools.cxx
@@ -53,7 +53,7 @@ namespace drawinglayer
                    r, g, b, 0,   r, g, b, 0,   r, g, b, 0,
                    0, 0, 0, a,   r, g, b, 0,   0, 0, 0, a
                 };
-                BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 3, 32);
+                BitmapEx aBitmap = vcl::bitmap::CreateFromData(cross, 3, 3, 12, 32);
 
                 // create and exchange at aRetVal
                 delete aRetVal.set(new BitmapEx(aBitmap));
diff --git a/vcl/source/bitmap/BitmapTools.cxx b/vcl/source/bitmap/BitmapTools.cxx
index ee0aef4f1f67..a171fd848a39 100644
--- a/vcl/source/bitmap/BitmapTools.cxx
+++ b/vcl/source/bitmap/BitmapTools.cxx
@@ -112,11 +112,11 @@ void loadFromSvg(SvStream& rStream, const OUString& sPath, BitmapEx& rBitmapEx,
     @param pData
     The block of data to copy
     @param nStride
-    The number of bytes in a scanline, must >= width
+    The number of bytes in a scanline, must >= (width * nBitCount / 8)
 */
 BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHeight, sal_Int32 nStride, sal_uInt16 nBitCount )
 {
-    assert(nStride >= nWidth);
+    assert(nStride >= (nWidth * nBitCount / 8));
     assert( nBitCount == 1 || nBitCount == 24 || nBitCount == 32);
     Bitmap aBmp( Size( nWidth, nHeight ), nBitCount );
 
@@ -135,12 +135,12 @@ BitmapEx CreateFromData( sal_uInt8 const *pData, sal_Int32 nWidth, sal_Int32 nHe
     {
         for( long y = 0; y < nHeight; ++y )
         {
-            sal_uInt8 const *p = pData + y * nStride;
             Scanline pScanline = pWrite->GetScanline(y);
             for (long x = 0; x < nWidth; ++x)
             {
-                pWrite->SetPixelOnData(pScanline, x, BitmapColor(*p));
-                ++p;
+                sal_uInt8 const *p = pData + y * nStride / 8;
+                int bitIndex = (y * nStride) % 8;
+                pWrite->SetPixelOnData(pScanline, x, BitmapColor((*p >> bitIndex) & 1));
             }
         }
     }


More information about the Libreoffice-commits mailing list