diff options
author | Armin Le Grand <alg@apache.org> | 2012-05-30 13:44:19 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-03-16 01:57:53 +0000 |
commit | a1a0830d1ac3ffabbe35bd8a0264b64f1f7a9d67 (patch) | |
tree | 7425273b6d0195397dfe635810bd48063c0d9054 | |
parent | e8620b247dcba55f67ad7eaf63cfe5ac3831b187 (diff) |
Resolves: #i119601# support for transparency in PNG export dialog
Added support for transparency in PNG export dialog and support for alpha
channnel
Conflicts:
svtools/source/filter/exportdialog.cxx
Change-Id: I324bfd6a34803478bf17f113e015620056c90567
-rw-r--r-- | drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx | 2 | ||||
-rw-r--r-- | svtools/source/filter/exportdialog.cxx | 13 | ||||
-rw-r--r-- | svx/source/unodraw/UnoGraphicExporter.cxx | 52 |
3 files changed, 45 insertions, 22 deletions
diff --git a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx index 30540cec2753..92e21d6736e3 100644 --- a/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx +++ b/drawinglayer/source/drawinglayeruno/xprimitive2drenderer.cxx @@ -145,7 +145,7 @@ namespace drawinglayer } const geometry::ViewInformation2D aViewInformation2D(aViewInformationSequence); - const double fFactor100th_mmToInch(2.54/1000.0); + const double fFactor100th_mmToInch(1.0 / (2.54 * 1000.0)); const sal_uInt32 nDiscreteWidth(basegfx::fround((fWidth * fFactor100th_mmToInch) * DPI_X)); const sal_uInt32 nDiscreteHeight(basegfx::fround((fHeight * fFactor100th_mmToInch) * DPI_Y)); diff --git a/svtools/source/filter/exportdialog.cxx b/svtools/source/filter/exportdialog.cxx index fdf73d65eb9a..b8942d56ba12 100644 --- a/svtools/source/filter/exportdialog.cxx +++ b/svtools/source/filter/exportdialog.cxx @@ -263,6 +263,10 @@ uno::Sequence< beans::PropertyValue > ExportDialog::GetFilterData( sal_Bool bUpd if ( mpCbInterlaced->IsChecked() ) nInterlace++; pFilterOptions->WriteInt32(OUString("Interlaced"), nInterlace); + sal_Int32 nValue = 0; + if ( mpCbSaveTransparency->IsChecked() ) + nValue++; + pFilterOptions->WriteInt32(OUString("Translucent"), nValue); } break; @@ -782,6 +786,7 @@ void ExportDialog::createFilterOptions() sal_Int32 nCompression = mpFilterOptionsItem->ReadInt32(OUString("Compression"), 6); if ( ( nCompression < 1 ) || ( nCompression > 9 ) ) nCompression = 6; + get(mpSbCompression, "compressionpngsb"); get(mpNfCompression, "compressionpngnf-nospin"); mpSbCompression->SetRangeMin( 1 ); @@ -793,7 +798,11 @@ void ExportDialog::createFilterOptions() // Interlaced mpMode->Show(); - mpCbInterlaced->Check( mpFilterOptionsItem->ReadInt32(OUString("Interlaced"), 0) != 0); + mpCbInterlaced->Check(mpFilterOptionsItem->ReadInt32(OUString("Interlaced"), 0) != 0); + + // Transparency + mpDrawingObjects->Show(); + mpCbSaveTransparency->Check(mpFilterOptionsItem->ReadInt32(OUString("Translucent"), 1) != 0); } break; case FORMAT_BMP : @@ -820,9 +829,11 @@ void ExportDialog::createFilterOptions() break; case FORMAT_GIF : { + // Interlaced mpMode->Show(); mpCbInterlaced->Check(mpFilterOptionsItem->ReadInt32(OUString("Interlaced"), 1) != 0); + // Transparency mpDrawingObjects->Show(); mpCbSaveTransparency->Check(mpFilterOptionsItem->ReadInt32(OUString("Translucent"), 1) != 0); } diff --git a/svx/source/unodraw/UnoGraphicExporter.cxx b/svx/source/unodraw/UnoGraphicExporter.cxx index 6efefc7f84f4..150094dd4650 100644 --- a/svx/source/unodraw/UnoGraphicExporter.cxx +++ b/svx/source/unodraw/UnoGraphicExporter.cxx @@ -207,34 +207,46 @@ namespace svx */ BitmapEx GetBitmapFromMetaFile( const GDIMetaFile& rMtf, sal_Bool bTransparent, const Size* pSize ) { - Graphic aGraphic( rMtf ); - BitmapEx aBmpEx; - - // #i102089# support user's settings of AA and LineSnap when the MetaFile gets - // rasterconverted to a bitmap - const SvtOptionsDrawinglayer aDrawinglayerOpt; - const GraphicConversionParameters aParameters( - pSize ? *pSize : Size(0, 0), - true, // allow unlimited size - aDrawinglayerOpt.IsAntiAliasing(), - aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete()); - - if( bTransparent ) + BitmapEx aBmpEx; + + if(bTransparent) { - Graphic aMaskGraphic(rMtf.GetMonochromeMtf(COL_BLACK)); - Bitmap aMaskBmp(aMaskGraphic.GetBitmap(aParameters)); + // use new primitive conversion tooling + basegfx::B2DRange aRange(basegfx::B2DPoint(0.0, 0.0)); + + if(pSize) + { + // use 100th mm for primitive bitmap converter tool, input is pixel + // use a real OutDev to get the correct DPI, the static LogicToLogic assumes 72dpi which is wrong (!) + const Size aSize100th(Application::GetDefaultDevice()->PixelToLogic(*pSize, MapMode(MAP_100TH_MM))); - aMaskBmp.Convert(BMP_CONVERSION_1BIT_THRESHOLD); - aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters), aMaskBmp); + aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); + } + else + { + // use 100th mm for primitive bitmap converter tool + const Size aSize100th(Application::GetDefaultDevice()->LogicToLogic(rMtf.GetPrefSize(), rMtf.GetPrefMapMode(), MapMode(MAP_100TH_MM))); + + aRange.expand(basegfx::B2DPoint(aSize100th.Width(), aSize100th.Height())); + } + + aBmpEx = convertMetafileToBitmapEx(rMtf, aRange); } else { + const SvtOptionsDrawinglayer aDrawinglayerOpt; + const GraphicConversionParameters aParameters( + pSize ? *pSize : Size(0, 0), + true, // allow unlimited size + aDrawinglayerOpt.IsAntiAliasing(), + aDrawinglayerOpt.IsSnapHorVerLinesToDiscrete()); + const Graphic aGraphic(rMtf); + aBmpEx = BitmapEx(aGraphic.GetBitmap(aParameters)); + aBmpEx.SetPrefMapMode( rMtf.GetPrefMapMode() ); + aBmpEx.SetPrefSize( rMtf.GetPrefSize() ); } - aBmpEx.SetPrefMapMode( rMtf.GetPrefMapMode() ); - aBmpEx.SetPrefSize( rMtf.GetPrefSize() ); - return aBmpEx; } |