summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2021-04-15 12:11:56 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-04-15 21:05:34 +0200
commitcb09533c4a007e7cfde69046bcaeb47117d30a86 (patch)
tree2977ff2a7d5efc5408b9e30e32a6684b7e561a3b
parentd0c7afcce3016759a1371be361ce8b39dfc7fc17 (diff)
tdf#141269 Incorrect transparency after roundtrip
Revert "convert internal bitmap formats transparency->alpha" This reverts commit c181e510c5f5e74f1f6824b64637849aace9ae63. and later fix up of Revert "tdf#141504 qt5: ugly images" This reverts commit e7424ff25a724ea5bb54b2282d5c3cbf74c92053. a lot of places are still working int transparency values and not opacity Change-Id: I31342cdb76629acbaebfcdfa385407d3291fe06f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/114150 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--canvas/source/directx/dx_canvasbitmap.cxx2
-rw-r--r--canvas/source/directx/dx_vcltools.cxx18
-rw-r--r--canvas/source/vcl/canvasbitmaphelper.cxx2
-rw-r--r--vcl/inc/bitmap/ScanlineTools.hxx2
-rw-r--r--vcl/qa/cppunit/ScanlineToolsTest.cxx10
-rw-r--r--vcl/qt5/Qt5Graphics_GDI.cxx2
-rw-r--r--vcl/skia/salbmp.cxx2
-rw-r--r--vcl/source/bitmap/BitmapEx.cxx2
-rw-r--r--vcl/source/gdi/gdimtf.cxx2
-rw-r--r--vcl/source/helper/canvasbitmap.cxx10
-rw-r--r--vcl/source/opengl/OpenGLHelper.cxx2
11 files changed, 32 insertions, 22 deletions
diff --git a/canvas/source/directx/dx_canvasbitmap.cxx b/canvas/source/directx/dx_canvasbitmap.cxx
index dba32d220434..adc4b741a4c3 100644
--- a/canvas/source/directx/dx_canvasbitmap.cxx
+++ b/canvas/source/directx/dx_canvasbitmap.cxx
@@ -218,7 +218,7 @@ namespace dxcanvas
sal_uInt8* pOutBits=pAlphaBits.get()+y*nScanWidth;
for( sal_Int32 x=0; x<aSize.getX(); ++x )
{
- *pOutBits++ = *pInBits;
+ *pOutBits++ = 255-*pInBits;
pInBits += 4;
}
}
diff --git a/canvas/source/directx/dx_vcltools.cxx b/canvas/source/directx/dx_vcltools.cxx
index d29043070ef3..5ed07159aba8 100644
--- a/canvas/source/directx/dx_vcltools.cxx
+++ b/canvas/source/directx/dx_vcltools.cxx
@@ -214,7 +214,11 @@ namespace dxcanvas::tools
*pCurrOutput++ = aCol.GetBlue();
*pCurrOutput++ = aCol.GetGreen();
*pCurrOutput++ = aCol.GetRed();
- *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
+
+ // our notion of alpha is
+ // different from the rest
+ // of the world's
+ *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
}
}
break;
@@ -230,7 +234,11 @@ namespace dxcanvas::tools
*pCurrOutput++ = *pScan++;
*pCurrOutput++ = *pScan++;
*pCurrOutput++ = *pScan++;
- *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
+
+ // our notion of alpha is
+ // different from the rest
+ // of the world's
+ *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
}
}
break;
@@ -253,7 +261,11 @@ namespace dxcanvas::tools
*pCurrOutput++ = aCol.GetBlue();
*pCurrOutput++ = aCol.GetGreen();
*pCurrOutput++ = aCol.GetRed();
- *pCurrOutput++ = static_cast<BYTE>(*pAScan++);
+
+ // our notion of alpha is
+ // different from the rest
+ // of the world's
+ *pCurrOutput++ = 255 - static_cast<BYTE>(*pAScan++);
}
}
break;
diff --git a/canvas/source/vcl/canvasbitmaphelper.cxx b/canvas/source/vcl/canvasbitmaphelper.cxx
index 2da1fe0ab0ad..dd1898486e8a 100644
--- a/canvas/source/vcl/canvasbitmaphelper.cxx
+++ b/canvas/source/vcl/canvasbitmaphelper.cxx
@@ -148,7 +148,7 @@ namespace vclcanvas
pRes[ 0 ] = aColor.GetRed();
pRes[ 1 ] = aColor.GetGreen();
pRes[ 2 ] = aColor.GetBlue();
- pRes[ 3 ] = aColor.GetAlpha();
+ pRes[ 3 ] = 255 - aColor.GetAlpha();
return aRes;
}
diff --git a/vcl/inc/bitmap/ScanlineTools.hxx b/vcl/inc/bitmap/ScanlineTools.hxx
index 98e702549f2b..c343cf34f61e 100644
--- a/vcl/inc/bitmap/ScanlineTools.hxx
+++ b/vcl/inc/bitmap/ScanlineTools.hxx
@@ -46,7 +46,7 @@ public:
virtual void writePixel(Color nColor) override
{
- *pData++ = nColor.GetAlpha();
+ *pData++ = 255 - nColor.GetAlpha();
*pData++ = nColor.GetRed();
*pData++ = nColor.GetGreen();
*pData++ = nColor.GetBlue();
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index 3a4fc7da9348..c6751b827ca1 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -42,9 +42,9 @@ void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
pScanlineTransformer->startLine(aScanLine.data());
std::vector<Color> aColors{
- Color(ColorAlpha, 255, 10, 250, 120), Color(ColorAlpha, 205, 30, 230, 110),
- Color(ColorAlpha, 155, 50, 210, 100), Color(ColorAlpha, 105, 70, 190, 90),
- Color(ColorAlpha, 55, 90, 170, 80),
+ Color(ColorTransparency, 0, 10, 250, 120), Color(ColorTransparency, 50, 30, 230, 110),
+ Color(ColorTransparency, 100, 50, 210, 100), Color(ColorTransparency, 150, 70, 190, 90),
+ Color(ColorTransparency, 200, 90, 170, 80),
};
for (Color const& aColor : aColors)
@@ -52,8 +52,8 @@ void ScanlineToolsTest::ScanlineTransformer_32_ARGB()
pScanlineTransformer->writePixel(aColor);
}
- std::vector<sal_uInt8> aExpectedBytes{ 255, 10, 250, 120, 205, 30, 230, 110, 155, 50,
- 210, 100, 105, 70, 190, 90, 55, 90, 170, 80 };
+ std::vector<sal_uInt8> aExpectedBytes{ 0, 10, 250, 120, 50, 30, 230, 110, 100, 50,
+ 210, 100, 150, 70, 190, 90, 200, 90, 170, 80 };
for (size_t i = 0; i < aScanLine.size(); ++i)
{
diff --git a/vcl/qt5/Qt5Graphics_GDI.cxx b/vcl/qt5/Qt5Graphics_GDI.cxx
index a2730be5ad4e..5d2bd964faca 100644
--- a/vcl/qt5/Qt5Graphics_GDI.cxx
+++ b/vcl/qt5/Qt5Graphics_GDI.cxx
@@ -623,7 +623,7 @@ static bool getAlphaImage(const SalBitmap& rSourceBitmap, const SalBitmap& rAlph
uchar* image_line = rAlphaImage.scanLine(y);
const uchar* alpha_line = pAlpha->scanLine(y);
for (int x = 0; x < rAlphaImage.width(); ++x, image_line += 4)
- image_line[3] = 255 - alpha_line[x];
+ image_line[3] = alpha_line[x];
}
}
else
diff --git a/vcl/skia/salbmp.cxx b/vcl/skia/salbmp.cxx
index bb19f9118637..b7909691d758 100644
--- a/vcl/skia/salbmp.cxx
+++ b/vcl/skia/salbmp.cxx
@@ -1326,7 +1326,7 @@ OString SkiaSalBitmap::GetAlphaImageKey() const
{
std::stringstream ss;
ss << std::hex << std::setfill('0') << std::setw(2)
- << static_cast<int>(SkColorGetA(fromEraseColorToAlphaImageColor(mEraseColor)));
+ << static_cast<int>(255 - SkColorGetA(fromEraseColorToAlphaImageColor(mEraseColor)));
return OStringLiteral("E") + ss.str().c_str();
}
return OStringLiteral("I") + OString::number(GetAlphaSkImage()->uniqueID());
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index 2aa41de865ba..7ff6af59f776 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -1554,7 +1554,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 ) ? 0 : (255 - nNewTrans) );
+ *pAScan++ = static_cast<sal_uInt8>( ( nNewTrans & 0xffffff00 ) ? 255 : nNewTrans );
}
}
}
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 7ef6c73ce47b..2856ecaed18e 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( ColorAlpha, rColor.GetAlpha(), cLum, cLum, cLum );
+ return Color( ColorTransparency, 255 - 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 6e6e80b9c623..26f4bdb8e412 100644
--- a/vcl/source/helper/canvasbitmap.cxx
+++ b/vcl/source/helper/canvasbitmap.cxx
@@ -521,8 +521,7 @@ 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);
- // convert alpha to transparency to preserve UNO compat
- *pOutBuf = 255 - m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X);
+ *pOutBuf = m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X);
}
else
{
@@ -532,8 +531,7 @@ uno::Sequence< sal_Int8 > SAL_CALL VclCanvasBitmap::getPixel( rendering::Integer
// input integer multiple of byte - copy directly
memcpy(pOutBuf, pScan+nScanlineLeftOffset, nNonAlphaBytes );
pOutBuf += nNonAlphaBytes;
- // convert alpha to transparency to preserve UNO compat
- *pOutBuf++ = 255 - m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X);
+ *pOutBuf++ = m_pAlphaAcc->GetPixelIndex(pos.Y,pos.X);
}
}
@@ -1278,7 +1276,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromARGB( co
m_pBmpAcc->SetPixelOnData(pColors,i,aCol2);
pColors += nNonAlphaBytes;
- *pColors++ = toByteColor(rgbColor[i].Alpha);
+ *pColors++ = 255 - toByteColor(rgbColor[i].Alpha);
}
}
else
@@ -1328,7 +1326,7 @@ uno::Sequence< ::sal_Int8 > SAL_CALL VclCanvasBitmap::convertIntegerFromPARGB( c
m_pBmpAcc->SetPixelOnData(pColors,i,aCol2);
pColors += nNonAlphaBytes;
- *pColors++ = toByteColor(nAlpha);
+ *pColors++ = 255 - toByteColor(nAlpha);
}
}
else
diff --git a/vcl/source/opengl/OpenGLHelper.cxx b/vcl/source/opengl/OpenGLHelper.cxx
index d67e5c6fc59a..ee2047548103 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++ = pBuffer[nCurPos++];
+ *pAlphaScan++ = static_cast<sal_uInt8>( 255 - pBuffer[nCurPos++] );
}
}
}