summaryrefslogtreecommitdiff
path: root/sdext/source
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2024-02-18 22:00:37 +0000
committerNoel Grandin <noel.grandin@collabora.co.uk>2024-02-29 08:23:28 +0100
commitb7a63d26466bac7eb7b25233a5a53788bed88c81 (patch)
tree280909e8bcc5d5e6ddaaac4ff4d8cd5e85844f69 /sdext/source
parent8ac5f40b330c6cd248073b8686c05f566ecd7195 (diff)
tdf#113050 sdext.pdfimport: Flip bitmap
We need to flip the bitmap between the wrapper and LO, but there's no easy way to do this in a Poly image fill in LO, so do it as a simple bitmap flip in the wrapper. Change-Id: Ifd84d37926c21edf30654d3884be975849a6dca3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163563 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sdext/source')
-rw-r--r--sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx44
1 files changed, 42 insertions, 2 deletions
diff --git a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
index 57eb30092141..ec2632b74899 100644
--- a/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
+++ b/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.cxx
@@ -432,8 +432,6 @@ static void writeImage_( OutputBuffer& o_rOutputBuf,
}
// forwarders
-
-
static void writeImageLF( OutputBuffer& o_rOutputBuf,
Stream* str,
int width,
@@ -445,6 +443,45 @@ static void writeMaskLF( OutputBuffer& o_rOutputBuf,
int height,
bool bInvert ) { writeMask_(o_rOutputBuf,str,width,height,bInvert); }
+// Vertically flip the bitmap
+static void flipSplashBitmap(SplashBitmap *pBitmap)
+{
+ if (pBitmap->getRowSize() <= 0)
+ return;
+
+ auto nBitmapHeight = static_cast<size_t>(pBitmap->getHeight());
+ auto nRowSize = static_cast<size_t>(pBitmap->getRowSize());
+ auto nAlphaRowSize = static_cast<size_t>(pBitmap->getAlphaRowSize());
+
+ auto aTmpRow = new unsigned char[nRowSize];
+ auto aTmpAlphaRow = new unsigned char[nAlphaRowSize];
+
+ auto pBitmapData = pBitmap->getDataPtr();
+ auto pAlphaData = pBitmap->getAlphaPtr();
+
+ // Set up pairs of pointers working from each end of the bitmap
+ auto pCurRowA = pBitmapData;
+ auto pCurAlphaA = pAlphaData;
+ auto pCurRowB = pBitmapData+nRowSize*(nBitmapHeight-1);
+ auto pCurAlphaB = pAlphaData+nAlphaRowSize*(nBitmapHeight-1);
+
+ for (size_t nCur = 0;
+ nCur < nBitmapHeight/2;
+ nCur++, pCurRowA+=nRowSize, pCurRowB-=nRowSize,
+ pCurAlphaA+=nAlphaRowSize, pCurAlphaB-=nAlphaRowSize)
+ {
+ memcpy(aTmpRow, pCurRowA, nRowSize);
+ memcpy(pCurRowA, pCurRowB, nRowSize);
+ memcpy(pCurRowB, aTmpRow, nRowSize);
+
+ memcpy(aTmpAlphaRow, pCurAlphaA, nAlphaRowSize);
+ memcpy(pCurAlphaA, pCurAlphaB, nAlphaRowSize);
+ memcpy(pCurAlphaB, aTmpAlphaRow, nAlphaRowSize);
+ }
+ delete[] aTmpRow;
+ delete[] aTmpAlphaRow;
+}
+
int PDFOutDev::parseFont( long long nNewId, GfxFont* gfxFont, const GfxState* state ) const
{
FontAttributes aNewFont;
@@ -1236,6 +1273,9 @@ poppler_bool PDFOutDev::tilingPatternFill(GfxState *state, Gfx *, Catalog *,
delete pSplashGfx;
delete pSplashOut;
+ // Add a vertical flip, we can't do this in LO for an image filled poly
+ flipSplashBitmap(pSplashBitmap);
+
auto nBitmapWidth = static_cast<size_t>(pSplashBitmap->getWidth());
auto nBitmapHeight = static_cast<size_t>(pSplashBitmap->getHeight());