summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Nabet <serval2412@yahoo.fr>2022-03-05 12:37:40 +0100
committerJulien Nabet <serval2412@yahoo.fr>2022-03-05 16:40:14 +0100
commiteed83764088bfdfcc6513778f7dc83d649f550a3 (patch)
tree023b1a9d6e081921d4e729b35aa541bb6e64258a
parent492098417a590521506e41c05d3ab0f09628d39a (diff)
tdf#136632: Use 'Save transparency' when exporting selected objects for PNG
To avoid some regression, consider that transparency should be enabled by default. So only remove transparency if it's required explicitely. + change QA test since "Translucent" property isn't a bool but a sal_Int32 In officecfg/registry/schema/org/openoffice/Office/Common.xcs: <prop oor:name="Translucent" oor:type="xs:int" oor:nillable="false"> Change-Id: I9bfb6aae8e2e8a31dee82f73a9165989129f222a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131057 Tested-by: Jenkins Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r--sd/qa/unit/PNGExportTests.cxx2
-rw-r--r--vcl/source/filter/png/pngwrite.cxx10
2 files changed, 10 insertions, 2 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index f80d2e6af384..f3ab40228953 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -240,7 +240,7 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf147119)
uno::Sequence<beans::PropertyValue> aFilterData{
comphelper::makePropertyValue("PixelWidth", sal_Int32(100)),
comphelper::makePropertyValue("PixelHeight", sal_Int32(100)),
- comphelper::makePropertyValue("Translucent", true),
+ comphelper::makePropertyValue("Translucent", sal_Int32(1)),
};
utl::TempFile aTempFile;
diff --git a/vcl/source/filter/png/pngwrite.cxx b/vcl/source/filter/png/pngwrite.cxx
index b4bc3fa8b60b..865fe38ebee7 100644
--- a/vcl/source/filter/png/pngwrite.cxx
+++ b/vcl/source/filter/png/pngwrite.cxx
@@ -124,6 +124,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
Bitmap aBmp(aBitmapEx.GetBitmap());
mnMaxChunkSize = std::numeric_limits<sal_uInt32>::max();
+ bool bTranslucent = true;
if (pFilterData)
{
@@ -133,6 +134,13 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
rPropVal.Value >>= mnCompLevel;
else if (rPropVal.Name == "Interlaced")
rPropVal.Value >>= mnInterlaced;
+ else if (rPropVal.Name == "Translucent")
+ {
+ tools::Long nTmp = 0;
+ rPropVal.Value >>= nTmp;
+ if (!nTmp)
+ bTranslucent = false;
+ }
else if (rPropVal.Name == "MaxChunkSize")
{
sal_Int32 nVal = 0;
@@ -143,7 +151,7 @@ PNGWriterImpl::PNGWriterImpl(const BitmapEx& rBitmapEx,
}
mnBitsPerPixel = sal_uInt8(vcl::pixelFormatBitCount(aBmp.getPixelFormat()));
- if (aBitmapEx.IsAlpha())
+ if (aBitmapEx.IsAlpha() && bTranslucent)
{
if (mnBitsPerPixel <= 8)
{