summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vcl/source/bitmap/BitmapEx.cxx15
-rw-r--r--xmloff/source/text/XMLTextFrameContext.cxx27
2 files changed, 26 insertions, 16 deletions
diff --git a/vcl/source/bitmap/BitmapEx.cxx b/vcl/source/bitmap/BitmapEx.cxx
index ebcb7aa1cb9a..c541579744b0 100644
--- a/vcl/source/bitmap/BitmapEx.cxx
+++ b/vcl/source/bitmap/BitmapEx.cxx
@@ -1286,11 +1286,12 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect,
std::unique_ptr<Point[]> pPoints2;
tools::Long nX, nY;
sal_uInt16 nPolyPos = 0;
- // tdf#161498 use COL_ALPHA_OPAQUE for finding opaque pixels
- // Starting with commit 81994cb2b8b32453a92bcb011830fcb884f22ff3,
- // pixels now contain an alpha value instead of a transparency
- // value.
- const BitmapColor aTransparencyOpaque = pAcc->GetBestMatchingColor( COL_ALPHA_OPAQUE );
+ // tdf#161833 treat semi-transparent pixels as opaque
+ // Limiting the contour wrapping polygon to only opaque pixels
+ // causes clipping of any shadows or other semi-transaprent
+ // areas in the image. So, instead of testing for fully opaque
+ // pixels, treat pixels that are not fully transparent as opaque.
+ const BitmapColor aTransparent = pAcc->GetBestMatchingColor( COL_ALPHA_TRANSPARENT );
pPoints1.reset(new Point[ nHeight ]);
pPoints2.reset(new Point[ nHeight ]);
@@ -1303,7 +1304,7 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect,
// scan row from left to right
while( nX < nEndX1 )
{
- if( aTransparencyOpaque == pAcc->GetPixelFromData( pScanline, nX ) )
+ if( aTransparent != pAcc->GetPixelFromData( pScanline, nX ) )
{
pPoints1[ nPolyPos ] = Point( nX, nY );
nX = nStartX2;
@@ -1311,7 +1312,7 @@ tools::Polygon BitmapEx::GetContour( bool bContourEdgeDetect,
// this loop always breaks eventually as there is at least one pixel
while( true )
{
- if( aTransparencyOpaque == pAcc->GetPixelFromData( pScanline, nX ) )
+ if( aTransparent != pAcc->GetPixelFromData( pScanline, nX ) )
{
pPoints2[ nPolyPos ] = Point( nX, nY );
break;
diff --git a/xmloff/source/text/XMLTextFrameContext.cxx b/xmloff/source/text/XMLTextFrameContext.cxx
index 87752f73b199..5c293c7670c2 100644
--- a/xmloff/source/text/XMLTextFrameContext.cxx
+++ b/xmloff/source/text/XMLTextFrameContext.cxx
@@ -271,17 +271,26 @@ XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
basegfx::B2DPolyPolygon aPolyPolygon;
- if( bPath )
+ // Related tdf#161833: ignore saved polygon for "recreate on edit" contours
+ // tdf#161833 would cause semi-transparent pixels to be treated as fully
+ // transparent pixels when calculating the wrap contour for an image. To
+ // force the correct contour when loading a document, force the contour
+ // to be recalculated by ignoring the saved polygon if the contour is set
+ // to "recreate on edit".
+ if( !bAuto )
{
- basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr);
- }
- else
- {
- basegfx::B2DPolygon aPolygon;
-
- if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints))
+ if( bPath )
{
- aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
+ basegfx::utils::importFromSvgD(aPolyPolygon, sD, GetImport().needFixPositionAfterZ(), nullptr);
+ }
+ else
+ {
+ basegfx::B2DPolygon aPolygon;
+
+ if(basegfx::utils::importFromSvgPoints(aPolygon, sPoints))
+ {
+ aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
+ }
}
}