diff options
author | Noel Grandin <noel@peralex.com> | 2021-01-07 09:46:07 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-02-23 11:20:35 +0100 |
commit | c181e510c5f5e74f1f6824b64637849aace9ae63 (patch) | |
tree | 31a658cbe4d8e1de92a1dcd39cd649a93f74685b /vcl/source | |
parent | d042b39c2f30246b51cba65400552c25a6dd5105 (diff) |
convert internal bitmap formats transparency->alpha
Image formats and graphics APIs use alpha, not transparency,
so change our internal formats and data structures to work directly
with alpha, so we don't need to modify data before we push it to
graphics APIs.
Change-Id: I537f77f79e83876be11d787901df42710d190842
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108919
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl/source')
-rw-r--r-- | vcl/source/bitmap/BitmapEx.cxx | 2 | ||||
-rw-r--r-- | vcl/source/gdi/gdimtf.cxx | 2 | ||||
-rw-r--r-- | vcl/source/helper/canvasbitmap.cxx | 10 | ||||
-rw-r--r-- | vcl/source/opengl/OpenGLHelper.cxx | 2 |
4 files changed, 9 insertions, 7 deletions
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx index 65698b6bbad9..c75aa12ed27b 100644 --- a/vcl/source/bitmap/BitmapEx.cxx +++ b/vcl/source/bitmap/BitmapEx.cxx @@ -1588,7 +1588,7 @@ void BitmapEx::AdjustTransparency(sal_uInt8 cTrans) for( tools::Long nX = 0; nX < nWidth; nX++ ) { nNewTrans = nTrans + *pAScan; - *pAScan++ = static_cast<sal_uInt8>( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans ); + *pAScan++ = static_cast<sal_uInt8>( ( nNewTrans & 0xffffff00 ) ? 0 : (255 - nNewTrans) ); } } } diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx index e42e7feedb87..96df06275afc 100644 --- a/vcl/source/gdi/gdimtf.cxx +++ b/vcl/source/gdi/gdimtf.cxx @@ -1751,7 +1751,7 @@ Color GDIMetaFile::ImplColConvertFnc( const Color& rColor, const void* pColParam if( MtfConversion::N1BitThreshold == static_cast<const ImplColConvertParam*>(pColParam)->eConversion ) cLum = ( cLum < 128 ) ? 0 : 255; - return Color( ColorTransparency, 255 - rColor.GetAlpha(), cLum, cLum, cLum ); + return Color( ColorAlpha, rColor.GetAlpha(), cLum, cLum, cLum ); } BitmapEx GDIMetaFile::ImplBmpConvertFnc( const BitmapEx& rBmpEx, const void* pBmpParam ) diff --git a/vcl/source/helper/canvasbitmap.cxx b/vcl/source/helper/canvasbitmap.cxx index 9cef26b7a19b..97a1293bfad7 100644 --- a/vcl/source/helper/canvasbitmap.cxx +++ b/vcl/source/helper/canvasbitmap.cxx @@ -564,7 +564,8 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer { // input less than a byte - copy via GetPixel() *pOutBuf++ = m_pBmpAcc->GetPixelIndex(pos.Y,pos.X); - *pOutBuf = m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X); + // convert alpha to transparency to preserve UNO compat + *pOutBuf = 255 - m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X); } else { @@ -574,7 +575,8 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer // input integer multiple of byte - copy directly memcpy(pOutBuf, pScan+nScanlineLeftOffset, nNonAlphaBytes ); pOutBuf += nNonAlphaBytes; - *pOutBuf++ = m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X); + // convert alpha to transparency to preserve UNO compat + *pOutBuf++ = 255 - m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X); } } @@ -1320,7 +1322,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromARGB( co m_pBmpAcc->SetPixelOnData(pColors,i,aCol2); pColors += nNonAlphaBytes; - *pColors++ = 255 - toByteColor(rgbColor[i].Alpha); + *pColors++ = toByteColor(rgbColor[i].Alpha); } } else @@ -1370,7 +1372,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromPARGB( c m_pBmpAcc->SetPixelOnData(pColors,i,aCol2); pColors += nNonAlphaBytes; - *pColors++ = 255 - toByteColor(nAlpha); + *pColors++ = toByteColor(nAlpha); } } else diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx index 82e01da1dc8d..2d9d3ce8c713 100644 --- a/vcl/source/opengl/OpenGLHelper.cxx +++ b/vcl/source/opengl/OpenGLHelper.cxx @@ -597,7 +597,7 @@ BitmapEx OpenGLHelper::ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, t *pScan++ = pBuffer[nCurPos+2]; nCurPos += 3; - *pAlphaScan++ = static_cast<sal_uInt8>( 255 - pBuffer[nCurPos++] ); + *pAlphaScan++ = pBuffer[nCurPos++]; } } } |