diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-10 10:48:41 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2017-02-10 14:08:23 +0100 |
commit | f9b32576553b2972194510cc808d12fe198bc8c8 (patch) | |
tree | 316a6cc85fa267b1d8e5914e2e6ddba5a6ffabf0 /xmlsecurity/workben | |
parent | 32c0ab80aa0dbe105be15c5feee4e3bd7cc5ee25 (diff) |
pdfverify preview: fix macOS color space
Unlike on Linux and Windows, we need to do an ARGB -> BGRA conversion
here.
Change-Id: Ifa539973de439de25125e544cfbbe941d08dee00
Diffstat (limited to 'xmlsecurity/workben')
-rw-r--r-- | xmlsecurity/workben/pdfverify.cxx | 21 |
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); |