[Libreoffice-commits] core.git: xmlsecurity/workben

Miklos Vajna vmiklos at collabora.co.uk
Fri Feb 10 13:09:14 UTC 2017


 xmlsecurity/workben/pdfverify.cxx |   21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

New commits:
commit f9b32576553b2972194510cc808d12fe198bc8c8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Feb 10 10:48:41 2017 +0100

    pdfverify preview: fix macOS color space
    
    Unlike on Linux and Windows, we need to do an ARGB -> BGRA conversion
    here.
    
    Change-Id: Ifa539973de439de25125e544cfbbe941d08dee00

diff --git a/xmlsecurity/workben/pdfverify.cxx b/xmlsecurity/workben/pdfverify.cxx
index dceb863..d481d15 100644
--- a/xmlsecurity/workben/pdfverify.cxx
+++ b/xmlsecurity/workben/pdfverify.cxx
@@ -85,11 +85,28 @@ void generatePreview(const OString& rPdfPath, const OString& rPngPath)
     Bitmap aBitmap(Size(nPageWidth, nPageHeight), 32);
     {
         Bitmap::ScopedWriteAccess pWriteAccess(aBitmap);
-        const void* pPdfBuffer = FPDFBitmap_GetBuffer(pPdfBitmap);
+        const char* pPdfBuffer = static_cast<const char*>(FPDFBitmap_GetBuffer(pPdfBitmap));
+#ifndef MACOSX
         std::memcpy(pWriteAccess->GetBuffer(), pPdfBuffer, nPageWidth * nPageHeight * 4);
+#else
+        // ARGB -> BGRA
+        for (int nRow = 0; nRow < nPageHeight; ++nRow)
+        {
+            int nStride = FPDFBitmap_GetStride(pPdfBitmap);
+            const char* pPdfLine = pPdfBuffer + (nStride * nRow);
+            Scanline pRow = pWriteAccess->GetBuffer() + (nPageWidth * nRow * 4);
+            for (int nCol = 0; nCol < nPageWidth; ++nCol)
+            {
+                pRow[nCol * 4] = pPdfLine[(nCol * 4) + 3];
+                pRow[(nCol * 4) + 1] = pPdfLine[(nCol * 4) + 2];
+                pRow[(nCol * 4) + 2] = pPdfLine[(nCol * 4) + 1];
+                pRow[(nCol * 4) + 3] = pPdfLine[nCol * 4];
+            }
+        }
+#endif
     }
     BitmapEx aBitmapEx(aBitmap);
-#ifdef WNT
+#if defined(WNT) || defined(MACOSX)
     aBitmapEx.Mirror(BmpMirrorFlags::Vertical);
 #endif
     vcl::PNGWriter aWriter(aBitmapEx);


More information about the Libreoffice-commits mailing list