diff options
author | Caolán McNamara <caolanm@redhat.com> | 2017-09-04 13:34:09 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2017-09-04 17:22:27 +0200 |
commit | 3cb59bff332b02f607d15b5ed41b4438e8102980 (patch) | |
tree | ce5a73ae6ba902bee269b7eda7806a22f4ca960a /vcl/headless | |
parent | 5f847b3d197a96e5c2bab3d9129d3dd9d5b75873 (diff) |
Resolves: tdf#111483 1 bit bitmaps with non-standard black/white indexes
can be left "untoggled" when converted to cairo A1
Change-Id: I18f3e2109cd4b57bce584545090e26c931de1200
Reviewed-on: https://gerrit.libreoffice.org/41895
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/headless')
-rw-r--r-- | vcl/headless/svpgdi.cxx | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/vcl/headless/svpgdi.cxx b/vcl/headless/svpgdi.cxx index ce01c4e89230..170d6c6087e6 100644 --- a/vcl/headless/svpgdi.cxx +++ b/vcl/headless/svpgdi.cxx @@ -113,6 +113,7 @@ namespace void Toggle1BitTransparency(const BitmapBuffer& rBuf) { + assert(rBuf.maPalette.GetBestIndex(BitmapColor(Color(COL_BLACK))) == 0); // TODO: make upper layers use standard alpha if (getCairoFormat(rBuf) == CAIRO_FORMAT_A1) { @@ -216,10 +217,14 @@ namespace pAlphaBits.reset( new unsigned char[nImageSize] ); memcpy(pAlphaBits.get(), pMaskBuf->mpBits, nImageSize); - // TODO: make upper layers use standard alpha - unsigned char* pDst = pAlphaBits.get(); - for (int i = nImageSize; --i >= 0; ++pDst) - *pDst = ~*pDst; + const sal_Int32 nBlackIndex = pMaskBuf->maPalette.GetBestIndex(BitmapColor(Color(COL_BLACK))); + if (nBlackIndex == 0) + { + // TODO: make upper layers use standard alpha + unsigned char* pDst = pAlphaBits.get(); + for (int i = nImageSize; --i >= 0; ++pDst) + *pDst = ~*pDst; + } mask = cairo_image_surface_create_for_data(pAlphaBits.get(), CAIRO_FORMAT_A1, |