tdf#141269 Incorrect transparency after roundtrip

Revert "convert internal bitmap formats transparency->alpha"

This reverts commit c181e510c5.

and later fix up of

Revert "tdf#141504 qt5: ugly images"

This reverts commit e7424ff25a.

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>
This commit is contained in:
Caolán McNamara
2021-04-15 21:05:34 +02:00
parent d0c7afcce3
commit cb09533c4a
11 changed files with 32 additions and 22 deletions
+1 -1
View File
@@ -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;
}
}
+15 -3
View File
@@ -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;
+1 -1
View File
@@ -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;
}
+1 -1
View File
@@ -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();
+5 -5
View File
@@ -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)
{
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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());
+1 -1
View File
@@ -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 );
}
}
}
+1 -1
View File
@@ -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 )
+4 -6
View File
@@ -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
+1 -1
View File
@@ -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++] );
}
}
}