summaryrefslogtreecommitdiff
path: root/xmlsecurity
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-02-10 10:48:41 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-14 11:24:38 +0100
commitc2ffe5e32de4f70e55aae88d6774f681ffa6a9dc (patch)
tree1960729347d57dd160233f1f4e34cd9a893978ac /xmlsecurity
parent6ab19d364c8238bd84d8b1474d0af7ed001e3217 (diff)
pdfverify preview: fix macOS color space
Unlike on Linux and Windows, we need to do an ARGB -> BGRA conversion here. Change-Id: Ifa539973de439de25125e544cfbbe941d08dee00 (cherry picked from commit f9b32576553b2972194510cc808d12fe198bc8c8)
Diffstat (limited to 'xmlsecurity')
-rw-r--r--xmlsecurity/workben/pdfverify.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/xmlsecurity/workben/pdfverify.cxx b/xmlsecurity/workben/pdfverify.cxx
index dceb863ca77b..d481d15e0472 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);