[Libreoffice-commits] core.git: avmedia/source basic/source canvas/source chart2/source drawinglayer/source dtrans/source editeng/source extensions/source filter/source fpicker/source framework/source include/sot include/svtools include/vcl lotuswordpro/source sc/source sd/source sfx2/source sot/source svtools/source svx/source sw/source toolkit/source vcl/aqua vcl/Library_vcl.mk vcl/source

Armin Le Grand alg at apache.org
Thu Jun 13 06:51:09 PDT 2013


 avmedia/source/win/framegrabber.cxx                        |    3 
 basic/source/runtime/methods.cxx                           |    5 
 canvas/source/cairo/cairo_devicehelper.cxx                 |    6 
 canvas/source/vcl/devicehelper.cxx                         |    7 
 canvas/source/vcl/spritedevicehelper.cxx                   |    7 
 chart2/source/controller/main/ChartController_Tools.cxx    |    6 
 chart2/source/controller/main/ChartTransferable.cxx        |    2 
 drawinglayer/source/processor2d/vclhelperbufferdevice.cxx  |    7 
 drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx |    1 
 drawinglayer/source/tools/converters.cxx                   |    4 
 dtrans/source/win32/dtobj/DOTransferable.cxx               |   12 
 dtrans/source/win32/dtobj/FmtFilter.cxx                    |   34 
 dtrans/source/win32/dtobj/FmtFilter.hxx                    |    2 
 dtrans/source/win32/dtobj/XTDataObject.cxx                 |   16 
 dtrans/source/win32/ftransl/ftransl.cxx                    |    3 
 editeng/source/items/bulitem.cxx                           |    8 
 extensions/source/scanner/sanedlg.cxx                      |    5 
 filter/source/graphicfilter/eos2met/eos2met.cxx            |    3 
 filter/source/graphicfilter/ios2met/ios2met.cxx            |    4 
 filter/source/msfilter/msdffimp.cxx                        |    3 
 filter/source/msfilter/mstoolbar.cxx                       |    3 
 fpicker/source/office/iodlg.cxx                            |    3 
 framework/source/fwe/classes/addonsoptions.cxx             |    3 
 framework/source/fwe/classes/imagewrapper.cxx              |    7 
 framework/source/fwe/helper/actiontriggerhelper.cxx        |    6 
 include/sot/formats.hxx                                    |    3 
 include/svtools/transfer.hxx                               |    8 
 include/vcl/alpha.hxx                                      |   17 
 include/vcl/bitmap.hxx                                     |   24 
 include/vcl/bitmapex.hxx                                   |    8 
 include/vcl/dibtools.hxx                                   |   70 
 include/vcl/pngwrite.hxx                                   |    2 
 include/vcl/salbtype.hxx                                   |   16 
 include/vcl/wall.hxx                                       |    2 
 lotuswordpro/source/filter/lwpbackgroundstuff.cxx          |    3 
 sc/source/filter/excel/xiescher.cxx                        |    5 
 sc/source/ui/app/drwtrans.cxx                              |    2 
 sc/source/ui/app/transobj.cxx                              |    2 
 sc/source/ui/docshell/docsh.cxx                            |    2 
 sc/source/ui/inc/viewfunc.hxx                              |    2 
 sc/source/ui/view/viewfun3.cxx                             |    6 
 sc/source/ui/view/viewfun5.cxx                             |    6 
 sc/source/ui/view/viewfun7.cxx                             |    4 
 sd/source/ui/app/sdxfer.cxx                                |    4 
 sd/source/ui/unoidl/unopage.cxx                            |    4 
 sd/source/ui/view/sdview3.cxx                              |    8 
 sfx2/source/appl/fileobj.cxx                               |   13 
 sfx2/source/appl/linkmgr2.cxx                              |    3 
 sfx2/source/dialog/filedlghelper.cxx                       |    3 
 sfx2/source/doc/docinf.cxx                                 |    6 
 sot/source/base/exchange.cxx                               |    1 
 svtools/source/graphic/graphic.cxx                         |    7 
 svtools/source/graphic/provider.cxx                        |    8 
 svtools/source/misc/transfer.cxx                           |  165 +
 svx/source/gallery2/galmisc.cxx                            |    2 
 svx/source/gallery2/galobj.cxx                             |   12 
 svx/source/sdr/overlay/overlaymanagerbuffered.cxx          |    1 
 svx/source/xoutdev/_xoutbmp.cxx                            |    6 
 svx/source/xoutdev/xattrbmp.cxx                            |    9 
 sw/source/core/view/viewsh.cxx                             |    4 
 sw/source/filter/ww1/w1filter.cxx                          |    8 
 sw/source/ui/dochdl/swdtflvr.cxx                           |    9 
 toolkit/source/awt/vclxbitmap.cxx                          |    8 
 toolkit/source/helper/vclunohelper.cxx                     |    9 
 vcl/Library_vcl.mk                                         |    2 
 vcl/aqua/source/dtrans/DataFlavorMapping.cxx               |   78 
 vcl/aqua/source/dtrans/OSXTransferable.cxx                 |    2 
 vcl/aqua/source/dtrans/PictToBmpFlt.cxx                    |  232 -
 vcl/aqua/source/dtrans/PictToBmpFlt.hxx                    |   23 
 vcl/source/filter/graphicfilter.cxx                        |    4 
 vcl/source/filter/wmf/emfwr.cxx                            |    3 
 vcl/source/filter/wmf/enhwmf.cxx                           |   10 
 vcl/source/filter/wmf/winwmf.cxx                           |    5 
 vcl/source/filter/wmf/wmfwr.cxx                            |    7 
 vcl/source/gdi/animate.cxx                                 |   12 
 vcl/source/gdi/bitmap2.cxx                                 | 1268 ----------
 vcl/source/gdi/bitmapex.cxx                                |  101 
 vcl/source/gdi/bmpconv.cxx                                 |   12 
 vcl/source/gdi/cvtsvm.cxx                                  |   22 
 vcl/source/gdi/dibtools.cxx                                | 1587 +++++++++++++
 vcl/source/gdi/impgraph.cxx                                |    5 
 vcl/source/gdi/impimagetree.cxx                            |    9 
 vcl/source/gdi/metaact.cxx                                 |   53 
 vcl/source/gdi/pdfwriter_impl2.cxx                         |    2 
 vcl/source/gdi/wall.cxx                                    |    9 
 85 files changed, 2238 insertions(+), 1840 deletions(-)

New commits:
commit e0cce521f1ad0cc384d30ce2f1077ea229fffe62
Author: Armin Le Grand <alg at apache.org>
Date:   Thu Jan 10 16:28:40 2013 +0000

    Resolves: #i121504# Support for alpha channel in clipboard for all systems
    
    (cherry picked from commit ef3931ff410117e1237b3bef7bc090e8b83b9519)
    
    Conflicts:
    	automation/source/server/statemnt.cxx
    	basic/source/runtime/methods.cxx
    	canvas/source/vcl/devicehelper.cxx
    	canvas/source/vcl/spritedevicehelper.cxx
    	drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
    	drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
    	drawinglayer/source/tools/converters.cxx
    	dtrans/source/win32/dtobj/FmtFilter.cxx
    	editeng/source/items/bulitem.cxx
    	extensions/source/scanner/sanedlg.cxx
    	external/gcc3_specific/makefile.mk
    	filter/source/graphicfilter/eos2met/eos2met.cxx
    	filter/source/graphicfilter/ios2met/ios2met.cxx
    	filter/source/msfilter/msdffimp.cxx
    	fpicker/source/office/iodlg.cxx
    	framework/source/fwe/classes/addonsoptions.cxx
    	framework/source/fwe/helper/actiontriggerhelper.cxx
    	sc/source/filter/excel/xiescher.cxx
    	sc/source/ui/docshell/docsh.cxx
    	sc/source/ui/inc/viewfunc.hxx
    	sd/source/ui/app/sdxfer.cxx
    	sd/source/ui/unoidl/unopage.cxx
    	sd/source/ui/view/sdview3.cxx
    	sfx2/source/appl/fileobj.cxx
    	sfx2/source/appl/linkmgr2.cxx
    	sfx2/source/dialog/filedlghelper.cxx
    	sfx2/source/dialog/intro.cxx
    	sfx2/source/doc/docinf.cxx
    	sot/inc/sot/formats.hxx
    	sot/source/base/formats.cxx
    	svtools/bmpmaker/bmpcore.cxx
    	svtools/bmpmaker/bmpsum.cxx
    	svtools/inc/svtools/transfer.hxx
    	svtools/source/filter/filter.cxx
    	svtools/source/filter/wmf/emfwr.cxx
    	svtools/source/filter/wmf/enhwmf.cxx
    	svtools/source/filter/wmf/winwmf.cxx
    	svtools/source/filter/wmf/wmfwr.cxx
    	svtools/source/graphic/graphic.cxx
    	svtools/source/graphic/provider.cxx
    	svtools/source/misc/transfer.cxx
    	svx/inc/svx/xoutbmp.hxx
    	svx/source/sdr/overlay/overlaymanagerbuffered.cxx
    	svx/source/xoutdev/_xoutbmp.cxx
    	sw/source/core/view/viewsh.cxx
    	sw/source/filter/ww1/w1filter.cxx
    	sw/source/filter/ww8/ww8par.hxx
    	sw/source/ui/dochdl/swdtflvr.cxx
    	toolkit/source/awt/vclxbitmap.cxx
    	toolkit/source/helper/vclunohelper.cxx
    	vcl/Library_vcl.mk
    	vcl/Package_inc.mk
    	vcl/aqua/source/dtrans/DataFlavorMapping.cxx
    	vcl/aqua/source/dtrans/OSXTransferable.cxx
    	vcl/aqua/source/dtrans/PictToBmpFlt.cxx
    	vcl/aqua/source/dtrans/PictToBmpFlt.hxx
    	vcl/inc/vcl/alpha.hxx
    	vcl/inc/vcl/bitmap.hxx
    	vcl/inc/vcl/bitmapex.hxx
    	vcl/inc/vcl/pngwrite.hxx
    	vcl/inc/vcl/salbtype.hxx
    	vcl/inc/vcl/wall.hxx
    	vcl/source/gdi/animate.cxx
    	vcl/source/gdi/bitmap2.cxx
    	vcl/source/gdi/bitmapex.cxx
    	vcl/source/gdi/bmpconv.cxx
    	vcl/source/gdi/cvtsvm.cxx
    	vcl/source/gdi/impgraph.cxx
    	vcl/source/gdi/impimagetree.cxx
    	vcl/source/gdi/metaact.cxx
    	vcl/source/gdi/wall.cxx
    
    Change-Id: I79938bc412c048c3d4e64f430f216e73bec16167

diff --git a/avmedia/source/win/framegrabber.cxx b/avmedia/source/win/framegrabber.cxx
index e72fc16..f5789e0 100644
--- a/avmedia/source/win/framegrabber.cxx
+++ b/avmedia/source/win/framegrabber.cxx
@@ -38,6 +38,7 @@
 #include <tools/stream.hxx>
 #include <vcl/graph.hxx>
 #include <unotools/localfilehelper.hxx>
+#include <vcl/dibtools.hxx>
 
 #define AVMEDIA_WIN_FRAMEGRABBER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.FrameGrabber_DirectX"
 #define AVMEDIA_WIN_FRAMEGRABBER_SERVICENAME "com.sun.star.media.FrameGrabber_DirectX"
@@ -182,7 +183,7 @@ uno::Reference< graphic::XGraphic > SAL_CALL FrameGrabber::grabFrame( double fMe
                         SvMemoryStream  aMemStm( pBuffer, nSize, STREAM_READ | STREAM_WRITE );
                         Bitmap          aBmp;
 
-                        if( aBmp.Read( aMemStm, false ) && !aBmp.IsEmpty() )
+                        if( ReadDIB(aBmp, aMemStm, false ) && !aBmp.IsEmpty() )
                         {
                             const Graphic aGraphic( aBmp );
                             xRet = aGraphic.GetXGraphic();
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 118c80a..1e49c1d 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -20,6 +20,7 @@
 #include <tools/date.hxx>
 #include <basic/sbxvar.hxx>
 #include <osl/process.h>
+#include <vcl/dibtools.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
 #include <vcl/sound.hxx>
@@ -4331,8 +4332,8 @@ RTLFUNC(LoadPicture)
     if( pStream != NULL )
     {
         Bitmap aBmp;
-        *pStream >> aBmp;
-        Graphic aGraphic( aBmp );
+        ReadDIB(aBmp, *pStream, true);
+        Graphic aGraphic(aBmp);
 
         SbxObjectRef xRef = new SbStdPicture;
         ((SbStdPicture*)(SbxObject*)xRef)->SetGraphic( aGraphic );
diff --git a/canvas/source/cairo/cairo_devicehelper.cxx b/canvas/source/cairo/cairo_devicehelper.cxx
index e8fe710..bbe3585 100644
--- a/canvas/source/cairo/cairo_devicehelper.cxx
+++ b/canvas/source/cairo/cairo_devicehelper.cxx
@@ -32,6 +32,7 @@
 #include <basegfx/tools/unopolypolygon.hxx>
 
 #include <vcl/canvastools.hxx>
+#include <vcl/dibtools.hxx>
 
 #include <tools/stream.hxx>
 
@@ -261,8 +262,9 @@ namespace cairocanvas
             const ::Point aEmptyPoint;
             bool bOldMap( mpRefDevice->IsMapModeEnabled() );
             mpRefDevice->EnableMapMode( sal_False );
-            aStream << mpRefDevice->GetBitmap(aEmptyPoint,
-                                              mpRefDevice->GetOutputSizePixel());
+            WriteDIB(mpRefDevice->GetBitmap(aEmptyPoint,
+                                              mpRefDevice->GetOutputSizePixel()), aStream, false, true);
+
             mpRefDevice->EnableMapMode( bOldMap );
 
             ++nFilePostfixCount;
diff --git a/canvas/source/vcl/devicehelper.cxx b/canvas/source/vcl/devicehelper.cxx
index 053326f..dc56874 100644
--- a/canvas/source/vcl/devicehelper.cxx
+++ b/canvas/source/vcl/devicehelper.cxx
@@ -17,23 +17,21 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <canvas/debug.hxx>
 #include <tools/diagnose_ex.h>
 #include <canvas/canvastools.hxx>
-
 #include <rtl/instance.hxx>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/canvastools.hxx>
 #include <basegfx/tools/canvastools.hxx>
 #include <basegfx/tools/unopolypolygon.hxx>
+#include <vcl/dibtools.hxx>
 
 #include "devicehelper.hxx"
 #include "spritecanvas.hxx"
 #include "spritecanvashelper.hxx"
 #include "canvasbitmap.hxx"
 
-
 using namespace ::com::sun::star;
 
 namespace vclcanvas
@@ -223,8 +221,7 @@ namespace vclcanvas
             OutputDevice& rOutDev = mpOutDev->getOutDev();
             bool bOldMap( rOutDev.IsMapModeEnabled() );
             rOutDev.EnableMapMode( sal_False );
-            aStream << rOutDev.GetBitmap(aEmptyPoint,
-                                         rOutDev.GetOutputSizePixel());
+            WriteDIB(rOutDev.GetBitmap(aEmptyPoint, rOutDev.GetOutputSizePixel()), aStream, false, true);
             rOutDev.EnableMapMode( bOldMap );
 
             ++nFilePostfixCount;
diff --git a/canvas/source/vcl/spritedevicehelper.cxx b/canvas/source/vcl/spritedevicehelper.cxx
index beaf354..5f89521 100644
--- a/canvas/source/vcl/spritedevicehelper.cxx
+++ b/canvas/source/vcl/spritedevicehelper.cxx
@@ -17,20 +17,18 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <canvas/debug.hxx>
 #include <canvas/canvastools.hxx>
-
 #include <toolkit/helper/vclunohelper.hxx>
 #include <vcl/canvastools.hxx>
 #include <basegfx/tools/canvastools.hxx>
+#include <vcl/dibtools.hxx>
 
 #include "spritedevicehelper.hxx"
 #include "spritecanvas.hxx"
 #include "spritecanvashelper.hxx"
 #include "canvasbitmap.hxx"
 
-
 using namespace ::com::sun::star;
 
 namespace vclcanvas
@@ -138,8 +136,7 @@ namespace vclcanvas
 
             const ::Point aEmptyPoint;
             mpBackBuffer->getOutDev().EnableMapMode( sal_False );
-            aStream << mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint,
-                                                            mpBackBuffer->getOutDev().GetOutputSizePixel());
+            WriteDIB(mpBackBuffer->getOutDev().GetBitmap(aEmptyPoint, mpBackBuffer->getOutDev().GetOutputSizePixel()), aStream, false, true);
         }
 
         ++nFilePostfixCount;
diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx
index 889be43..c25770f 100644
--- a/chart2/source/controller/main/ChartController_Tools.cxx
+++ b/chart2/source/controller/main/ChartController_Tools.cxx
@@ -294,9 +294,9 @@ void ChartController::executeDispatch_Paste()
             else if( aDataHelper.HasFormat( FORMAT_BITMAP ))
             {
                 // bitmap (non-graphic-manager)
-                Bitmap aBmp;
-                if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ))
-                    aGraphic = Graphic( aBmp );
+                BitmapEx aBmpEx;
+                if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ))
+                    aGraphic = Graphic( aBmpEx );
             }
             else if( aDataHelper.HasFormat( FORMAT_STRING ))
             {
diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx
index a1742ea..7e63605 100644
--- a/chart2/source/controller/main/ChartTransferable.cxx
+++ b/chart2/source/controller/main/ChartTransferable.cxx
@@ -94,7 +94,7 @@ sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataF
         else if( nFormat == FORMAT_BITMAP )
         {
             Graphic aGraphic( m_xMetaFileGraphic );
-            bResult = SetBitmap( aGraphic.GetBitmap(), rFlavor );
+            bResult = SetBitmapEx( aGraphic.GetBitmapEx(), rFlavor );
         }
     }
 
diff --git a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
index f87afc62..0dbd56e 100644
--- a/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
+++ b/drawinglayer/source/processor2d/vclhelperbufferdevice.cxx
@@ -25,6 +25,7 @@
 #include <vcl/timer.hxx>
 #include <comphelper/broadcasthelper.hxx>
 #include <vcl/lazydelete.hxx>
+#include <vcl/dibtools.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // buffered VDev usage
@@ -292,7 +293,7 @@ namespace drawinglayer
             if(bDoSaveForVisualControl)
             {
                 SvFileStream aNew((const String&)String( "c:\\content.bmp" ), STREAM_WRITE|STREAM_TRUNC);
-                aNew << aContent;
+                WriteDIB(aContent, aNew, false, true);
             }
 
             if(mpAlpha)
@@ -303,7 +304,7 @@ namespace drawinglayer
                 if(bDoSaveForVisualControl)
                 {
                     SvFileStream aNew((const String&)String( "c:\\transparence.bmp" ), STREAM_WRITE|STREAM_TRUNC);
-                    aNew << aAlphaMask.GetBitmap();
+                    WriteDIB(aAlphaMask.GetBitmap(), aNew, false, true);
                 }
 
                 mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aAlphaMask));
@@ -316,7 +317,7 @@ namespace drawinglayer
                 if(bDoSaveForVisualControl)
                 {
                     SvFileStream aNew((const String&)String( "c:\\mask.bmp" ), STREAM_WRITE|STREAM_TRUNC);
-                    aNew << aMask;
+                    WriteDIB(aMask, aNew, false, true);
                 }
 
                 mrOutDev.DrawBitmapEx(maDestPixel.TopLeft(), BitmapEx(aContent, aMask));
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index acf1a7e..378961fb 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -54,6 +54,7 @@
 #include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
 #include <drawinglayer/primitive2d/epsprimitive2d.hxx>
 #include <basegfx/polygon/b2dlinegeometry.hxx>
+#include <vcl/dibtools.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 // for PDFExtOutDevData Graphic support
diff --git a/drawinglayer/source/tools/converters.cxx b/drawinglayer/source/tools/converters.cxx
index dc53f27..1bbbe43 100644
--- a/drawinglayer/source/tools/converters.cxx
+++ b/drawinglayer/source/tools/converters.cxx
@@ -27,6 +27,7 @@
 
 #ifdef DBG_UTIL
 #include <tools/stream.hxx>
+#include <vcl/pngwrite.hxx>
 #endif
 
 //////////////////////////////////////////////////////////////////////////////
@@ -123,7 +124,8 @@ namespace drawinglayer
             if(bDoSaveForVisualControl)
             {
                 SvFileStream aNew(OUString("c:\\test.png"), STREAM_WRITE|STREAM_TRUNC);
-                aNew << aRetval;
+                ::vcl::PNGWriter aPNGWriter(aRetval);
+                aPNGWriter.Write(aNew);
             }
 #endif
 
diff --git a/dtrans/source/win32/dtobj/DOTransferable.cxx b/dtrans/source/win32/dtobj/DOTransferable.cxx
index 30d887d..7e35ac2 100644
--- a/dtrans/source/win32/dtobj/DOTransferable.cxx
+++ b/dtrans/source/win32/dtobj/DOTransferable.cxx
@@ -338,10 +338,14 @@ CDOTransferable::ByteSequence_t SAL_CALL CDOTransferable::getClipboardData( CFor
             clipDataToByteStream( aFormatEtc.getClipformat( ), stgmedium, byteStream );
 
             // format conversion if necessary
-            if ( CF_DIB == aFormatEtc.getClipformat() )
-                byteStream = WinDIBToOOBMP( byteStream );
-            else if ( CF_METAFILEPICT == aFormatEtc.getClipformat() )
-                byteStream = WinMFPictToOOMFPict( byteStream );
+            if(CF_DIBV5 == aFormatEtc.getClipformat() || CF_DIB == aFormatEtc.getClipformat())
+            {
+                byteStream = WinDIBToOOBMP(byteStream);
+            }
+            else if(CF_METAFILEPICT == aFormatEtc.getClipformat())
+            {
+                byteStream = WinMFPictToOOMFPict(byteStream);
+            }
         }
 
         ReleaseStgMedium( &stgmedium );
diff --git a/dtrans/source/win32/dtobj/FmtFilter.cxx b/dtrans/source/win32/dtobj/FmtFilter.cxx
index f9327d8..199d301 100644
--- a/dtrans/source/win32/dtobj/FmtFilter.cxx
+++ b/dtrans/source/win32/dtobj/FmtFilter.cxx
@@ -190,28 +190,31 @@ HENHMETAFILE SAL_CALL OOMFPictToWinENHMFPict( Sequence< sal_Int8 >& aOOMetaFileP
 
 Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const Sequence< sal_Int8 >& aWinDIB )
 {
-    OSL_ASSERT( aWinDIB.getLength( ) > sizeof( BITMAPINFOHEADER ) );
-
+    OSL_ENSURE(aWinDIB.getLength() > sizeof(BITMAPINFOHEADER), "CF_DIBV5/CF_DIB too small (!)");
     Sequence< sal_Int8 > ooBmpStream;
 
-    ooBmpStream.realloc( aWinDIB.getLength( ) + sizeof(BITMAPFILEHEADER) );
-
-    const BITMAPINFOHEADER  *pBmpInfoHdr = (const BITMAPINFOHEADER*)aWinDIB.getConstArray();
-    BITMAPFILEHEADER        *pBmpFileHdr = reinterpret_cast< BITMAPFILEHEADER* >( ooBmpStream.getArray() );
-    DWORD                   nOffset      = sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER );
+    ooBmpStream.realloc(aWinDIB.getLength( ) + sizeof(BITMAPFILEHEADER));
+    const BITMAPINFOHEADER* pBmpInfoHdr = reinterpret_cast< const BITMAPINFOHEADER* >(aWinDIB.getConstArray());
+    BITMAPFILEHEADER* pBmpFileHdr = reinterpret_cast< BITMAPFILEHEADER* >(ooBmpStream.getArray());
+    const DWORD nSizeInfoOrV5(pBmpInfoHdr->biSize > sizeof(BITMAPINFOHEADER) ? sizeof(BITMAPV5HEADER) : sizeof(BITMAPINFOHEADER));
+    DWORD nOffset(sizeof(BITMAPFILEHEADER) + nSizeInfoOrV5);
 
-    memcpy( pBmpFileHdr + 1, pBmpInfoHdr, aWinDIB.getLength( ) );
+    memcpy(pBmpFileHdr + 1, pBmpInfoHdr, aWinDIB.getLength());
 
-    if( pBmpInfoHdr->biBitCount <= 8 )
-        nOffset += ( pBmpInfoHdr->biClrUsed ? pBmpInfoHdr->biClrUsed : ( 1 << pBmpInfoHdr->biBitCount ) ) << 2;
-    else if( ( BI_BITFIELDS == pBmpInfoHdr->biCompression ) && ( ( 16 == pBmpInfoHdr->biBitCount ) || ( 32 == pBmpInfoHdr->biBitCount ) ) )
+    if(pBmpInfoHdr->biBitCount <= 8)
+    {
+        nOffset += (pBmpInfoHdr->biClrUsed ? pBmpInfoHdr->biClrUsed : (1 << pBmpInfoHdr->biBitCount)) << 2;
+    }
+    else if((BI_BITFIELDS == pBmpInfoHdr->biCompression ) && ((16 == pBmpInfoHdr->biBitCount ) || (32 == pBmpInfoHdr->biBitCount )))
+    {
         nOffset += 12;
+    }
 
-    pBmpFileHdr->bfType      = ('M' << 8) | 'B';
-    pBmpFileHdr->bfSize      = 0; // maybe: nMemSize + sizeof(BITMAPFILEHEADER)
+    pBmpFileHdr->bfType = ('M' << 8) | 'B';
+    pBmpFileHdr->bfSize = 0; // maybe: nMemSize + sizeof(BITMAPFILEHEADER)
     pBmpFileHdr->bfReserved1 = 0;
     pBmpFileHdr->bfReserved2 = 0;
-    pBmpFileHdr->bfOffBits   = nOffset;
+    pBmpFileHdr->bfOffBits = nOffset;
 
     return ooBmpStream;
 }
@@ -222,9 +225,6 @@ Sequence< sal_Int8 > SAL_CALL WinDIBToOOBMP( const Sequence< sal_Int8 >& aWinDIB
 
 Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( Sequence< sal_Int8 >& aOOBmp )
 {
-    OSL_ASSERT( aOOBmp.getLength( ) >
-                ( sizeof( BITMAPFILEHEADER ) + sizeof( BITMAPINFOHEADER ) ) );
-
     Sequence< sal_Int8 > winDIBStream( aOOBmp.getLength( ) - sizeof( BITMAPFILEHEADER ) );
 
     memcpy( winDIBStream.getArray( ),
diff --git a/dtrans/source/win32/dtobj/FmtFilter.hxx b/dtrans/source/win32/dtobj/FmtFilter.hxx
index a77d0a5..b9f06b5 100644
--- a/dtrans/source/win32/dtobj/FmtFilter.hxx
+++ b/dtrans/source/win32/dtobj/FmtFilter.hxx
@@ -64,6 +64,8 @@ com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL WinBITMAPToOOBMP( HBITMAP );
 /*------------------------------------------------------------------------
     input:
     aOOBmp - sequence of bytes containing a openoffice bitmap
+    May contain CF_DIBV5 or CF_DIB, but removing the BITMAPFILEHEADER
+    is always the same size
 ------------------------------------------------------------------------*/
 com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL OOBmpToWinDIB( com::sun::star::uno::Sequence< sal_Int8 >& aOOBmp );
 
diff --git a/dtrans/source/win32/dtobj/XTDataObject.cxx b/dtrans/source/win32/dtobj/XTDataObject.cxx
index c213517..90805fb 100644
--- a/dtrans/source/win32/dtobj/XTDataObject.cxx
+++ b/dtrans/source/win32/dtobj/XTDataObject.cxx
@@ -298,8 +298,22 @@ void SAL_CALL CXTDataObject::renderAnyDataAndSetupStgMedium(
         nRequiredMemSize = sizeof( sal_Int8 ) * clipDataStream.getLength( ) + 1;
 
     // prepare data for transmision
-    if ( CF_DIB == fetc.cfFormat )
+    if ( CF_DIBV5 == fetc.cfFormat || CF_DIB == fetc.cfFormat )
+    {
+#ifdef DBG_UTIL
+        if(CF_DIBV5 == fetc.cfFormat)
+        {
+            OSL_ENSURE(clipDataStream.getLength( ) > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPV5HEADER)), "Wrong size on CF_DIBV5 data (!)");
+        }
+        else // CF_DIB == fetc.cfFormat
+        {
+            OSL_ENSURE(clipDataStream.getLength( ) > (sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)), "Wrong size on CF_DIB data (!)");
+        }
+#endif
+
+        // remove BITMAPFILEHEADER
         clipDataStream = OOBmpToWinDIB( clipDataStream );
+    }
 
     if ( CF_METAFILEPICT == fetc.cfFormat )
     {
diff --git a/dtrans/source/win32/ftransl/ftransl.cxx b/dtrans/source/win32/ftransl/ftransl.cxx
index 70724c1..b808fe8 100644
--- a/dtrans/source/win32/ftransl/ftransl.cxx
+++ b/dtrans/source/win32/ftransl/ftransl.cxx
@@ -254,6 +254,7 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable()
     //SOT_FORMATSTR_ID_DIF
     m_TranslTable.push_back(FormatEntry("application/x-openoffice-dif;windows_formatname=\"DIF\"", "DIF", "DIF", CF_DIF, CPPUTYPE_DEFAULT));
     // SOT_FORMAT_BITMAP
+    m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIBV5, CPPUTYPE_DEFAULT));
     m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_DIB, CPPUTYPE_DEFAULT));
     m_TranslTable.push_back(FormatEntry("application/x-openoffice-bitmap;windows_formatname=\"Bitmap\"", "Bitmap", "Bitmap", CF_BITMAP, CPPUTYPE_DEFAULT));
     // SOT_FORMAT_STRING
@@ -485,6 +486,8 @@ void SAL_CALL CDataFormatTranslator::initTranslationTable()
     m_TranslTable.push_back(FormatEntry("application/vnd.sun.xml.dialog", "Dialog 6.0", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
     //SOT_FORMATSTR_ID_BMP
     m_TranslTable.push_back(FormatEntry("image/bmp", "Windows Bitmap", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
+    //SOT_FORMATSTR_ID_PNG
+    m_TranslTable.push_back(FormatEntry("image/png", "PNG", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
     //SOT_FORMATSTR_ID_DUMMY3
     m_TranslTable.push_back(FormatEntry("application/x-openoffice-dummy3;windows_formatname=\"SO_DUMMYFORMAT_3\"", "SO_DUMMYFORMAT_3", NULL, CF_INVALID, CPPUTYPE_DEFAULT));
     //SOT_FORMATSTR_ID_DUMMY4
diff --git a/editeng/source/items/bulitem.cxx b/editeng/source/items/bulitem.cxx
index c8de24a..e76869e 100644
--- a/editeng/source/items/bulitem.cxx
+++ b/editeng/source/items/bulitem.cxx
@@ -24,6 +24,7 @@
 #include <editeng/editrids.hrc>
 
 #include <tools/tenccvt.hxx>
+#include <vcl/dibtools.hxx>
 
 #define BULITEM_VERSION     ((sal_uInt16)2)
 
@@ -126,7 +127,8 @@ SvxBulletItem::SvxBulletItem( SvStream& rStrm, sal_uInt16 _nWhich ) :
         // Ignore Errorcode when reading Bitmap,
         // see comment in SvxBulletItem::Store()
         sal_Bool bOldError = rStrm.GetError() ? sal_True : sal_False;
-        rStrm >> aBmp;
+        ReadDIB(aBmp, rStrm, true);
+
         if ( !bOldError && rStrm.GetError() )
         {
             rStrm.ResetError();
@@ -332,7 +334,9 @@ SvStream& SvxBulletItem::Store( SvStream& rStrm, sal_uInt16 /*nItemVersion*/ ) c
         const Bitmap aBmp( pGraphicObject->GetGraphic().GetBitmap() );
         sal_uLong nBytes = aBmp.GetSizeBytes();
         if ( nBytes < sal_uLong(0xFF00*nFac) )
-            rStrm << aBmp;
+        {
+            WriteDIB(aBmp, rStrm, false, true);
+        }
 
         sal_uLong nEnd = rStrm.Tell();
         // Item can not write with an overhead more than 64K or SfxMultiRecord
diff --git a/extensions/source/scanner/sanedlg.cxx b/extensions/source/scanner/sanedlg.cxx
index f13b243..42fd73a 100644
--- a/extensions/source/scanner/sanedlg.cxx
+++ b/extensions/source/scanner/sanedlg.cxx
@@ -17,11 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <tools/config.hxx>
-
+#include <vcl/dibtools.hxx>
 #include <vcl/msgbox.hxx>
 #include <sanedlg.hxx>
 #include <sanedlg.hrc>
@@ -734,7 +733,7 @@ void SaneDlg::AcquirePreview()
         fprintf( stderr, "Previewbitmapstream contains %d bytes\n", (int)aTransporter.getStream().Tell() );
 #endif
         aTransporter.getStream().Seek( STREAM_SEEK_TO_BEGIN );
-        maPreviewBitmap.Read( aTransporter.getStream(), sal_True );
+        ReadDIB(maPreviewBitmap, aTransporter.getStream(), true);
     }
 
     SetAdjustedNumericalValue( "resolution", fResl );
diff --git a/filter/source/graphicfilter/eos2met/eos2met.cxx b/filter/source/graphicfilter/eos2met/eos2met.cxx
index 761c456..fc9efad 100644
--- a/filter/source/graphicfilter/eos2met/eos2met.cxx
+++ b/filter/source/graphicfilter/eos2met/eos2met.cxx
@@ -35,6 +35,7 @@
 #include <vcl/msgbox.hxx>
 #include <svl/solar.hrc>
 #include <vcl/gdimetafiletools.hxx>
+#include <vcl/dibtools.hxx>
 
 // -----------------------------Field Types-------------------------------
 
@@ -562,7 +563,7 @@ void METWriter::WriteImageObject(const Bitmap & rBitmap)
     WriteFieldId(nActBitmapId);
 
     // generate Windows-BMP file
-    aTemp << rBitmap;
+    WriteDIB(rBitmap, aTemp, false, true);
 
     // read header of the Windows-BMP file:
     aTemp.SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
diff --git a/filter/source/graphicfilter/ios2met/ios2met.cxx b/filter/source/graphicfilter/ios2met/ios2met.cxx
index 834bd11..b50ce69 100644
--- a/filter/source/graphicfilter/ios2met/ios2met.cxx
+++ b/filter/source/graphicfilter/ios2met/ios2met.cxx
@@ -17,9 +17,9 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <vcl/graph.hxx>
 #include <tools/poly.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/virdev.hxx>
 #include <vcl/lineinfo.hxx>
 
@@ -2362,7 +2362,7 @@ void OS2METReader::ReadField(sal_uInt16 nFieldType, sal_uInt16 nFieldSize)
             }
             pBitmapList->pBMP->Seek(0);
 
-            pBitmapList->aBitmap.Read( *( pBitmapList->pBMP ), sal_False );
+            ReadDIB(pBitmapList->aBitmap, *(pBitmapList->pBMP), false);
 
             if (pBitmapList->pBMP->GetError()!=0) {
                 pOS2MET->SetError(SVSTREAM_FILEFORMAT_ERROR);
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index a80bdfd..a580c43 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -114,6 +114,7 @@
 #include "svx/gallery.hxx"
 #include <com/sun/star/drawing/ShadeMode.hpp>
 #include <svl/itempool.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/svapp.hxx>
 #include <svx/svx3ditems.hxx>
 #include <svx/svdoashp.hxx>
@@ -6325,7 +6326,7 @@ sal_Bool SvxMSDffManager::GetBLIPDirect( SvStream& rBLIPStream, Graphic& rData,
         if( ( nInst & 0xFFFE ) == 0x7A8 )
         {   // getting the DIBs immediately
             Bitmap aNew;
-            if( aNew.Read( *pGrStream, sal_False ) )
+            if( ReadDIB(aNew, *pGrStream, false) )
             {
                 rData = Graphic( aNew );
                 nRes = GRFILTER_OK;
diff --git a/filter/source/msfilter/mstoolbar.cxx b/filter/source/msfilter/mstoolbar.cxx
index fd08ddc..0088fc7 100644
--- a/filter/source/msfilter/mstoolbar.cxx
+++ b/filter/source/msfilter/mstoolbar.cxx
@@ -15,6 +15,7 @@
 #include <com/sun/star/ui/ItemStyle.hpp>
 #include <com/sun/star/frame/XLayoutManager.hpp>
 #include <fstream>
+#include <vcl/dibtools.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/bitmapex.hxx>
 #include <vcl/image.hxx>
@@ -712,7 +713,7 @@ bool TBCBitMap::Read( SvStream& rS)
     nOffSet = rS.Tell();
     rS >> cbDIB;
     // cbDIB = sizeOf(biHeader) + sizeOf(colors) + sizeOf(bitmapData) + 10
-    return mBitMap.Read( rS, sal_False, sal_True );
+    return ReadDIB(mBitMap, rS, false);
 }
 
 void TBCBitMap::Print( FILE* fp )
diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx
index 1ed7a8c..f4c8d3a 100644
--- a/fpicker/source/office/iodlg.cxx
+++ b/fpicker/source/office/iodlg.cxx
@@ -71,6 +71,7 @@
 #include <comphelper/string.hxx>
 
 #include <osl/file.h>
+#include <vcl/dibtools.hxx>
 #include <vcl/waitobj.hxx>
 
 #include <com/sun/star/task/InteractionHandler.hpp>
@@ -3024,7 +3025,7 @@ void SvtFileDialog::setImage( sal_Int16 /*aImageFormat*/, const Any& rImage )
         SvMemoryStream  aData( aBmpSequence.getArray(),
                                aBmpSequence.getLength(),
                                STREAM_READ );
-        aData >> aBmp;
+        ReadDIB(aBmp, aData, true);
 
         _pPrevBmp->SetBitmap( aBmp );
     }
diff --git a/framework/source/fwe/classes/addonsoptions.cxx b/framework/source/fwe/classes/addonsoptions.cxx
index 0fdc325..a94fe1c 100644
--- a/framework/source/fwe/classes/addonsoptions.cxx
+++ b/framework/source/fwe/classes/addonsoptions.cxx
@@ -29,6 +29,7 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/uri.hxx>
 #include <comphelper/processfactory.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/graph.hxx>
 #include <vcl/graphicfilter.hxx>
 
@@ -1661,7 +1662,7 @@ sal_Bool AddonsOptions_Impl::CreateImageFromSequence( Image& rImage, sal_Bool bB
         SvMemoryStream  aMemStream( rBitmapDataSeq.getArray(), rBitmapDataSeq.getLength(), STREAM_STD_READ );
         BitmapEx        aBitmapEx;
 
-        aMemStream >> aBitmapEx;
+        ReadDIBBitmapEx(aBitmapEx, aMemStream);
 
         // Scale bitmap to fit the correct size for the menu/toolbar. Use best quality
         if ( aBitmapEx.GetSizePixel() != aSize )
diff --git a/framework/source/fwe/classes/imagewrapper.cxx b/framework/source/fwe/classes/imagewrapper.cxx
index 054a63a..ac42ab5 100644
--- a/framework/source/fwe/classes/imagewrapper.cxx
+++ b/framework/source/fwe/classes/imagewrapper.cxx
@@ -25,6 +25,7 @@
 #include <vcl/bitmapex.hxx>
 #include <tools/stream.hxx>
 #include <cppuhelper/typeprovider.hxx>
+#include <vcl/dibtools.hxx>
 
 using namespace com::sun::star::lang;
 using namespace com::sun::star::uno;
@@ -72,7 +73,7 @@ Sequence< sal_Int8 > SAL_CALL ImageWrapper::getDIB() throw ( RuntimeException )
     SolarMutexGuard aGuard;
 
     SvMemoryStream aMem;
-    aMem << m_aImage.GetBitmapEx().GetBitmap();
+    WriteDIB(m_aImage.GetBitmapEx().GetBitmap(), aMem, false, true);
     return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
 }
 
@@ -84,13 +85,13 @@ Sequence< sal_Int8 > SAL_CALL ImageWrapper::getMaskDIB() throw ( RuntimeExceptio
     if ( aBmpEx.IsAlpha() )
     {
         SvMemoryStream aMem;
-        aMem << aBmpEx.GetAlpha().GetBitmap();
+        WriteDIB(aBmpEx.GetAlpha().GetBitmap(), aMem, false, true);
         return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     }
     else if ( aBmpEx.IsTransparent() )
     {
         SvMemoryStream aMem;
-        aMem << aBmpEx.GetMask();
+        WriteDIB(aBmpEx.GetMask(), aMem, false, true);
         return Sequence< sal_Int8 >( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     }
 
diff --git a/framework/source/fwe/helper/actiontriggerhelper.cxx b/framework/source/fwe/helper/actiontriggerhelper.cxx
index 67fdd65..96149e4 100644
--- a/framework/source/fwe/helper/actiontriggerhelper.cxx
+++ b/framework/source/fwe/helper/actiontriggerhelper.cxx
@@ -30,7 +30,7 @@
 #include <tools/stream.hxx>
 #include <cppuhelper/weak.hxx>
 #include <comphelper/processfactory.hxx>
-
+#include <vcl/dibtools.hxx>
 
 const sal_uInt16 START_ITEMID = 1000;
 
@@ -183,7 +183,7 @@ void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, Reference< XIndexC
                                     {
                                         aDIBSeq = xBitmap->getDIB();
                                         SvMemoryStream aMem( (void *)aDIBSeq.getConstArray(), aDIBSeq.getLength(), STREAM_READ );
-                                        aMem >> aBitmap;
+                                        ReadDIB(aBitmap, aMem, true);
                                     }
 
                                     aDIBSeq = xBitmap->getMaskDIB();
@@ -191,7 +191,7 @@ void InsertSubMenuItems( Menu* pSubMenu, sal_uInt16& nItemId, Reference< XIndexC
                                     {
                                         Bitmap aMaskBitmap;
                                         SvMemoryStream aMem( (void *)aDIBSeq.getConstArray(), aDIBSeq.getLength(), STREAM_READ );
-                                        aMem >> aMaskBitmap;
+                                        ReadDIB(aMaskBitmap, aMem, true);
                                         aImage = Image( aBitmap, aMaskBitmap );
                                     }
                                     else
diff --git a/include/sot/formats.hxx b/include/sot/formats.hxx
index 9129476..74d3552 100644
--- a/include/sot/formats.hxx
+++ b/include/sot/formats.hxx
@@ -175,7 +175,8 @@
 #define SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE    ((sal_uLong)138)
 #define SOT_FORMATSTR_ID_STARBASE_8             ((sal_uLong)139)
 #define SOT_FORMATSTR_ID_HC_GDIMETAFILE         ((sal_uLong)140)
-#define SOT_FORMATSTR_ID_USER_END               SOT_FORMATSTR_ID_HC_GDIMETAFILE
+#define SOT_FORMATSTR_ID_PNG                    ((sal_uLong)141)
+#define SOT_FORMATSTR_ID_USER_END               SOT_FORMATSTR_ID_PNG
 
 #endif // _SOT_FORMATS_HXX
 
diff --git a/include/svtools/transfer.hxx b/include/svtools/transfer.hxx
index 5d63d16..4f8966b 100644
--- a/include/svtools/transfer.hxx
+++ b/include/svtools/transfer.hxx
@@ -40,7 +40,7 @@
 #include <com/sun/star/embed/Aspects.hpp>
 #include <com/sun/star/io/XInputStream.hpp>
 
-class Bitmap;
+class BitmapEx;
 class GDIMetaFile;
 class Graphic;
 class ImageMap;
@@ -224,7 +224,7 @@ protected:
 
     sal_Bool            SetAny( const ::com::sun::star::uno::Any& rAny, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     sal_Bool            SetString( const OUString& rString, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
-    sal_Bool            SetBitmap( const Bitmap& rBitmap, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
+    sal_Bool            SetBitmapEx( const BitmapEx& rBitmap, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     sal_Bool            SetGDIMetaFile( const GDIMetaFile& rMtf, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     sal_Bool            SetGraphic( const Graphic& rGraphic, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
     sal_Bool            SetImageMap( const ImageMap& rIMap, const ::com::sun::star::datatransfer::DataFlavor& rFlavor );
@@ -321,8 +321,8 @@ public:
     sal_Bool                    GetString( SotFormatStringId nFormat, OUString& rStr );
     sal_Bool                    GetString( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, OUString& rStr );
 
-    sal_Bool                    GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp );
-    sal_Bool                    GetBitmap( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, Bitmap& rBmp );
+    sal_Bool                    GetBitmapEx( SotFormatStringId nFormat, BitmapEx& rBmp );
+    sal_Bool                    GetBitmapEx( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, BitmapEx& rBmp );
 
     sal_Bool                    GetGDIMetaFile( SotFormatStringId nFormat, GDIMetaFile& rMtf );
     sal_Bool                    GetGDIMetaFile( const ::com::sun::star::datatransfer::DataFlavor& rFlavor, GDIMetaFile& rMtf );
diff --git a/include/vcl/alpha.hxx b/include/vcl/alpha.hxx
index 95bb0ea..4ad3e28 100644
--- a/include/vcl/alpha.hxx
+++ b/include/vcl/alpha.hxx
@@ -32,11 +32,10 @@ class BitmapEx;
 
 class VCL_DLLPUBLIC AlphaMask : private Bitmap
 {
+private:
     friend class BitmapEx;
     friend class OutputDevice;
-    friend VCL_DLLPUBLIC SvStream& operator<<( SvStream&, const ImageList& );
-
-private:
+    friend bool VCL_DLLPUBLIC ReadDIBBitmapEx(BitmapEx& rTarget, SvStream& rIStm);
 
     SAL_DLLPRIVATE const Bitmap&    ImplGetBitmap() const;
     SAL_DLLPRIVATE void             ImplSetBitmap( const Bitmap& rBitmap );
@@ -130,18 +129,6 @@ public:
         ScopedReadAccess;
     typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, AlphaMask, &AlphaMask::AcquireWriteAccess >
         ScopedWriteAccess;
-
-    sal_Bool    Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True )
-    {
-        return Bitmap::Read( rIStm, bFileHeader );
-    }
-    sal_Bool    Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const
-    {
-        return Bitmap::Write( rOStm, bCompressed, bFileHeader );
-    }
-
-    friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx );
-    friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx );
 };
 
 #endif // _SV_ALPHA_HXX
diff --git a/include/vcl/bitmap.hxx b/include/vcl/bitmap.hxx
index a5388fa..b4e07fb 100644
--- a/include/vcl/bitmap.hxx
+++ b/include/vcl/bitmap.hxx
@@ -290,8 +290,6 @@ class   BitmapWriteAccess;
 class   BitmapPalette;
 class   ImpBitmap;
 class   Color;
-class   SvStream;
-struct  DIBInfoHeader;
 class   ResId;
 class   GDIMetaFile;
 class   AlphaMask;
@@ -328,20 +326,6 @@ public:
     SAL_DLLPRIVATE void                 ImplSetImpBitmap( ImpBitmap* pImpBmp );
     SAL_DLLPRIVATE void                 ImplAssignWithSize( const Bitmap& rBitmap );
 
-    SAL_DLLPRIVATE static sal_Bool      ImplReadDIB( SvStream& rIStm, Bitmap& rBmp, sal_uLong nOffset, sal_Bool bMSOFormat = sal_False );
-    SAL_DLLPRIVATE static sal_Bool      ImplReadDIBFileHeader( SvStream& rIStm, sal_uLong& rOffset );
-    SAL_DLLPRIVATE static sal_Bool      ImplReadDIBInfoHeader( SvStream& rIStm, DIBInfoHeader& rHeader, sal_Bool& bTopDown, sal_Bool bMSOFormat = sal_False );
-    SAL_DLLPRIVATE static sal_Bool      ImplReadDIBPalette( SvStream& rIStm, BitmapWriteAccess& rAcc, sal_Bool bQuad );
-    SAL_DLLPRIVATE static sal_Bool      ImplReadDIBBits( SvStream& rIStm, DIBInfoHeader& rHeader, BitmapWriteAccess& rAcc, sal_Bool bTopDown );
-    SAL_DLLPRIVATE sal_Bool             ImplWriteDIB( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bCompressed ) const;
-    SAL_DLLPRIVATE static sal_Bool      ImplWriteDIBFileHeader( SvStream& rOStm, BitmapReadAccess& rAcc );
-    SAL_DLLPRIVATE static sal_Bool      ImplWriteDIBPalette( SvStream& rOStm, BitmapReadAccess& rAcc );
-    SAL_DLLPRIVATE static sal_Bool      ImplWriteDIBBits( SvStream& rOStm, BitmapReadAccess& rAcc,
-                                                            sal_uLong nCompression, sal_uInt32& rImageSize );
-    SAL_DLLPRIVATE static void          ImplDecodeRLE( sal_uInt8* pBuffer, DIBInfoHeader& rHeader,
-                                                            BitmapWriteAccess& rAcc, sal_Bool bRLE4 );
-    SAL_DLLPRIVATE static sal_Bool      ImplWriteRLE( SvStream& rOStm, BitmapReadAccess& rAcc, sal_Bool bRLE4 );
-
     SAL_DLLPRIVATE void                 ImplAdaptBitCount(Bitmap& rNew) const;
     SAL_DLLPRIVATE sal_Bool             ImplScaleFast( const double& rScaleX, const double& rScaleY );
     SAL_DLLPRIVATE sal_Bool             ImplScaleInterpolate( const double& rScaleX, const double& rScaleY );
@@ -865,14 +849,6 @@ public:
         ScopedReadAccess;
     typedef vcl::ScopedBitmapAccess< BitmapWriteAccess, Bitmap, &Bitmap::AcquireWriteAccess >
         ScopedWriteAccess;
-
-public:
-
-    sal_Bool                    Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True, sal_Bool bMSOFormat = sal_False );
-    sal_Bool                    Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const;
-
-    friend VCL_DLLPUBLIC SvStream&        operator>>( SvStream& rIStm, Bitmap& rBitmap );
-    friend VCL_DLLPUBLIC SvStream&        operator<<( SvStream& rOStm, const Bitmap& rBitmap );
 };
 
 inline sal_Bool Bitmap::operator!() const
diff --git a/include/vcl/bitmapex.hxx b/include/vcl/bitmapex.hxx
index ce1b2ae..f26ef96 100644
--- a/include/vcl/bitmapex.hxx
+++ b/include/vcl/bitmapex.hxx
@@ -48,9 +48,9 @@ enum TransparentType
 
 class VCL_DLLPUBLIC BitmapEx
 {
-    friend class ImpGraphic;
-
 private:
+    friend class ImpGraphic;
+    friend bool VCL_DLLPUBLIC WriteDIBBitmapEx(const BitmapEx& rSource, SvStream& rOStm);
 
     Bitmap              aBitmap;
     Bitmap              aMask;
@@ -65,8 +65,6 @@ public:
     SAL_DLLPRIVATE  ImpBitmap*  ImplGetBitmapImpBitmap() const { return aBitmap.ImplGetImpBitmap(); }
     SAL_DLLPRIVATE  ImpBitmap*  ImplGetMaskImpBitmap() const { return aMask.ImplGetImpBitmap(); }
 
-public:
-
                         BitmapEx();
                         BitmapEx( const ResId& rResId );
                         BitmapEx( const BitmapEx& rBitmapEx );
@@ -385,8 +383,6 @@ public:
 
 public:
 
-    friend VCL_DLLPUBLIC SvStream&  operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx );
-    friend VCL_DLLPUBLIC SvStream&  operator>>( SvStream& rIStm, BitmapEx& rBitmapEx );
     static BitmapEx AutoScaleBitmap(BitmapEx & aBitmap, const long aStandardSize);
 
     /// populate from a canvas implementation
diff --git a/include/vcl/dibtools.hxx b/include/vcl/dibtools.hxx
new file mode 100644
index 0000000..a8b0336
--- /dev/null
+++ b/include/vcl/dibtools.hxx
@@ -0,0 +1,70 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ *   Licensed to the Apache Software Foundation (ASF) under one or more
+ *   contributor license agreements. See the NOTICE file distributed
+ *   with this work for additional information regarding copyright
+ *   ownership. The ASF licenses this file to you under the Apache
+ *   License, Version 2.0 (the "License"); you may not use this file
+ *   except in compliance with the License. You may obtain a copy of
+ *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _SV_DIBTOOLS_HXX
+#define _SV_DIBTOOLS_HXX
+
+#include <vcl/dllapi.h>
+#include <vcl/mapmod.hxx>
+#include <tools/rc.hxx>
+#include <vcl/region.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+// predefines
+
+class SvStream;
+class BitmapEx;
+class Bitmap;
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool VCL_DLLPUBLIC ReadDIB( // ReadDIB(rBitmap, rIStm, true);
+    Bitmap& rTarget,
+    SvStream& rIStm,
+    bool bFileHeader);
+
+bool VCL_DLLPUBLIC ReadDIBBitmapEx(
+    BitmapEx& rTarget,
+    SvStream& rIStm);
+
+bool VCL_DLLPUBLIC ReadDIBV5(
+    Bitmap& rTarget,
+    Bitmap& rTargetAlpha,
+    SvStream& rIStm);
+
+//////////////////////////////////////////////////////////////////////////////
+
+bool VCL_DLLPUBLIC WriteDIB( // WriteDIB(rBitmap, rOStm, false, true);
+    const Bitmap& rSource,
+    SvStream& rOStm,
+    bool bCompressed,
+    bool bFileHeader);
+
+bool VCL_DLLPUBLIC WriteDIBBitmapEx(
+    const BitmapEx& rSource,
+    SvStream& rOStm);
+
+bool VCL_DLLPUBLIC WriteDIBV5(
+    const Bitmap& rSource,
+    const Bitmap& rSourceAlpha,
+    SvStream& rOStm);
+
+//////////////////////////////////////////////////////////////////////////////
+
+#endif // _SV_DIBTOOLS_HXX
+
+//////////////////////////////////////////////////////////////////////////////
diff --git a/include/vcl/pngwrite.hxx b/include/vcl/pngwrite.hxx
index 921ad45..bff25ad 100644
--- a/include/vcl/pngwrite.hxx
+++ b/include/vcl/pngwrite.hxx
@@ -40,7 +40,7 @@ namespace vcl
 
     public:
 
-        PNGWriter( const BitmapEx& BmpEx,
+        explicit PNGWriter( const BitmapEx&,
             const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >* pFilterData = NULL );
         ~PNGWriter();
 
diff --git a/include/vcl/salbtype.hxx b/include/vcl/salbtype.hxx
index 3fc153d..f926262 100644
--- a/include/vcl/salbtype.hxx
+++ b/include/vcl/salbtype.hxx
@@ -240,6 +240,7 @@ public:
     inline void         SetColorFor24Bit( const BitmapColor& rColor, HPBYTE pPixel ) const;
 
     inline void         GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel ) const;
+    inline void         GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, ConstHPBYTE pPixel ) const;
     inline void         SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const;
 };
 
@@ -863,6 +864,21 @@ inline void ColorMask::GetColorFor32Bit( BitmapColor& rColor, ConstHPBYTE pPixel
 
 // ------------------------------------------------------------------
 
+inline void ColorMask::GetColorAndAlphaFor32Bit( BitmapColor& rColor, sal_uInt8& rAlpha, ConstHPBYTE pPixel ) const
+{
+#ifdef OSL_BIGENDIAN
+    const sal_uInt32 nVal = (sal_uInt32) pPixel[ 0 ] | ( (sal_uInt32) pPixel[ 1 ] << 8UL ) |
+                        ( (sal_uInt32) pPixel[ 2 ] << 16UL ) | ( (sal_uInt32) pPixel[ 3 ] << 24UL );
+#else
+    const sal_uInt32 nVal = *(sal_uInt32*) pPixel;
+#endif
+    rAlpha = (sal_uInt8)(nVal >> 24);
+
+    MASK_TO_COLOR( nVal, mnRMask, mnGMask, mnBMask, mnRShift, mnGShift, mnBShift, rColor );
+}
+
+// ------------------------------------------------------------------
+
 inline void ColorMask::SetColorFor32Bit( const BitmapColor& rColor, HPBYTE pPixel ) const
 {
 #ifdef OSL_BIGENDIAN
diff --git a/include/vcl/wall.hxx b/include/vcl/wall.hxx
index e18adf7..18a90d3 100644
--- a/include/vcl/wall.hxx
+++ b/include/vcl/wall.hxx
@@ -92,7 +92,7 @@ public:
                     Wallpaper();
                     Wallpaper( const Wallpaper& rWallpaper );
                     Wallpaper( const Color& rColor );
-                    Wallpaper( const BitmapEx& rBmpEx );
+                    explicit Wallpaper( const BitmapEx& rBmpEx );
                     Wallpaper( const Gradient& rGradient );
                     ~Wallpaper();
 
diff --git a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
index 46bd2ed..2b9da1c 100644
--- a/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
+++ b/lotuswordpro/source/filter/lwpbackgroundstuff.cxx
@@ -64,6 +64,7 @@
 #include "xfilter/xfbgimage.hxx"
 
 #include "tools/stream.hxx"
+#include "vcl/dibtools.hxx"
 #include "vcl/bmpacc.hxx"
 #include "svx/xbitmap.hxx"
 
@@ -159,7 +160,7 @@ XFBGImage* LwpBackgroundStuff::GetFillPattern()
     // transfer image data from XOBitmap->SvStream->BYTE-Array
     SvMemoryStream aPicMemStream;
     aXOBitmap.Array2Bitmap();
-    aXOBitmap.GetBitmap().Write(aPicMemStream);
+    WriteDIB(aXOBitmap.GetBitmap(), aPicMemStream, true, true);
     sal_uInt32 nSize = aPicMemStream.GetEndOfData();
     sal_uInt8* pImageBuff = new sal_uInt8 [nSize];
     memcpy(pImageBuff, aPicMemStream.GetData(), nSize);
diff --git a/sc/source/filter/excel/xiescher.cxx b/sc/source/filter/excel/xiescher.cxx
index 354ea14..89d3840 100644
--- a/sc/source/filter/excel/xiescher.cxx
+++ b/sc/source/filter/excel/xiescher.cxx
@@ -45,6 +45,7 @@
 #include <sfx2/objsh.hxx>
 #include <unotools/moduleoptions.hxx>
 #include <unotools/fltrcfg.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/wmf.hxx>
 #include <comphelper/types.hxx>
 #include <comphelper/classids.hxx>
@@ -745,7 +746,7 @@ void XclImpDrawObjBase::ConvertFillStyle( SdrObject& rSdrObj, const XclObjFillDa
                 aMemStrm << sal_uInt32( pnPattern[ nIdx ] ); // 32-bit little-endian
             aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
             Bitmap aBitmap;
-            aBitmap.Read( aMemStrm, sal_False );
+            ReadDIB(aBitmap, aMemStrm, false);
 
             XOBitmap aXOBitmap( aBitmap );
             aXOBitmap.Bitmap2Array();
@@ -4054,7 +4055,7 @@ void XclImpDrawing::ReadBmp( Graphic& rGraphic, const XclImpRoot& rRoot, XclImpS
     // import the graphic from memory stream
     aMemStrm.Seek( STREAM_SEEK_TO_BEGIN );
     Bitmap aBitmap;
-    if( aBitmap.Read( aMemStrm, false ) )   // read DIB without file header
+    if( ReadDIB(aBitmap, aMemStrm, false) )   // read DIB without file header
         rGraphic = aBitmap;
 }
 
diff --git a/sc/source/ui/app/drwtrans.cxx b/sc/source/ui/app/drwtrans.cxx
index fab510e..ba018ef 100644
--- a/sc/source/ui/app/drwtrans.cxx
+++ b/sc/source/ui/app/drwtrans.cxx
@@ -427,7 +427,7 @@ sal_Bool ScDrawTransferObj::GetData( const ::com::sun::star::datatransfer::DataF
             if ( nFormat == SOT_FORMAT_GDIMETAFILE )
                 bOK = SetGDIMetaFile( aView.GetMarkedObjMetaFile(true), rFlavor );
             else
-                bOK = SetBitmap( aView.GetMarkedObjBitmapEx(true).GetBitmap(), rFlavor );
+                bOK = SetBitmapEx( aView.GetMarkedObjBitmapEx(true), rFlavor );
         }
         else if ( nFormat == SOT_FORMATSTR_ID_SVXB )
         {
diff --git a/sc/source/ui/app/transobj.cxx b/sc/source/ui/app/transobj.cxx
index 8d77350..1fecb49 100644
--- a/sc/source/ui/app/transobj.cxx
+++ b/sc/source/ui/app/transobj.cxx
@@ -350,7 +350,7 @@ sal_Bool ScTransferObj::GetData( const datatransfer::DataFlavor& rFlavor )
 
             aVirtDev.SetMapMode( MapMode( MAP_PIXEL ) );
             Bitmap aBmp = aVirtDev.GetBitmap( Point(), aVirtDev.GetOutputSize() );
-            bOK = SetBitmap( aBmp, rFlavor );
+            bOK = SetBitmapEx( aBmp, rFlavor );
         }
         else if ( nFormat == SOT_FORMAT_GDIMETAFILE )
         {
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 11c5439..c3c7705 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -3169,6 +3169,4 @@ bool ScDocShell::GetProtectionHash( /*out*/ ::com::sun::star::uno::Sequence< sal
     return bRes;
 }
 
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/viewfunc.hxx b/sc/source/ui/inc/viewfunc.hxx
index 7203b6b..3c6364c 100644
--- a/sc/source/ui/inc/viewfunc.hxx
+++ b/sc/source/ui/inc/viewfunc.hxx
@@ -130,7 +130,7 @@ public:
 
     sal_Bool            PasteFile( const Point&, const String&, sal_Bool bLink=false );
     sal_Bool            PasteObject( const Point&, const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >&, const Size* = NULL, const Graphic* = NULL, const OUString& = OUString(), sal_Int64 nAspect = ::com::sun::star::embed::Aspects::MSOLE_CONTENT );
-    sal_Bool            PasteBitmap( const Point&, const Bitmap& );
+    sal_Bool            PasteBitmapEx( const Point&, const BitmapEx& );
     sal_Bool            PasteMetaFile( const Point&, const GDIMetaFile& );
     sal_Bool            PasteGraphic( const Point& rPos, const Graphic& rGraphic,
                                     const String& rFile, const String& rFilter );
diff --git a/sc/source/ui/view/viewfun3.cxx b/sc/source/ui/view/viewfun3.cxx
index 9f091a6..afc2831 100644
--- a/sc/source/ui/view/viewfun3.cxx
+++ b/sc/source/ui/view/viewfun3.cxx
@@ -719,9 +719,9 @@ sal_Bool ScViewFunc::PasteOnDrawObject( const uno::Reference<datatransfer::XTran
         }
         else if ( aDataHelper.HasFormat( SOT_FORMAT_BITMAP ) )
         {
-            Bitmap aBmp;
-            if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
-                bRet = ApplyGraphicToObject( pHitObj, Graphic(aBmp) );
+            BitmapEx aBmpEx;
+            if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) )
+                bRet = ApplyGraphicToObject( pHitObj, Graphic(aBmpEx) );
         }
     }
     else
diff --git a/sc/source/ui/view/viewfun5.cxx b/sc/source/ui/view/viewfun5.cxx
index 1611c7f..200a3fd 100644
--- a/sc/source/ui/view/viewfun5.cxx
+++ b/sc/source/ui/view/viewfun5.cxx
@@ -454,9 +454,9 @@ sal_Bool ScViewFunc::PasteDataFormat( sal_uLong nFormatId,
     }
     else if (nFormatId == SOT_FORMAT_BITMAP)
     {
-        Bitmap aBmp;
-        if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
-            bRet = PasteBitmap( aPos, aBmp );
+        BitmapEx aBmpEx;
+        if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) )
+            bRet = PasteBitmapEx( aPos, aBmpEx );
     }
     else if (nFormatId == SOT_FORMAT_GDIMETAFILE)
     {
diff --git a/sc/source/ui/view/viewfun7.cxx b/sc/source/ui/view/viewfun7.cxx
index 922c781..8fa0e38 100644
--- a/sc/source/ui/view/viewfun7.cxx
+++ b/sc/source/ui/view/viewfun7.cxx
@@ -359,10 +359,10 @@ sal_Bool ScViewFunc::PasteObject( const Point& rPos, const uno::Reference < embe
         return false;
 }
 
-sal_Bool ScViewFunc::PasteBitmap( const Point& rPos, const Bitmap& rBmp )
+sal_Bool ScViewFunc::PasteBitmapEx( const Point& rPos, const BitmapEx& rBmpEx )
 {
     String aEmpty;
-    Graphic aGraphic(rBmp);
+    Graphic aGraphic(rBmpEx);
     return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
 }
 
diff --git a/sd/source/ui/app/sdxfer.cxx b/sd/source/ui/app/sdxfer.cxx
index 16397d3..b13af5d 100644
--- a/sd/source/ui/app/sdxfer.cxx
+++ b/sd/source/ui/app/sdxfer.cxx
@@ -505,10 +505,10 @@ sal_Bool SdTransferable::GetData( const DataFlavor& rFlavor )
             if( mpSdViewIntern )
                 bOK = SetGDIMetaFile( mpSdViewIntern->GetMarkedObjMetaFile( true ), rFlavor );
         }
-        else if( nFormat == FORMAT_BITMAP )
+        else if( FORMAT_BITMAP == nFormat || SOT_FORMATSTR_ID_PNG == nFormat )
         {
             if( mpSdViewIntern )
-                bOK = SetBitmap( mpSdViewIntern->GetMarkedObjBitmapEx( true ).GetBitmap(), rFlavor );
+                bOK = SetBitmapEx( mpSdViewIntern->GetMarkedObjBitmapEx(true), rFlavor );
         }
         else if( ( nFormat == FORMAT_STRING ) && mpBookmark )
         {
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 1fb509a..cb09121 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -51,7 +51,6 @@
 #include <osl/mutex.hxx>
 #include <svl/style.hxx>
 #include <comphelper/serviceinfohelper.hxx>
-
 #include <comphelper/extract.hxx>
 #include <list>
 #include <svx/svditer.hxx>
@@ -68,6 +67,7 @@
 #include "unokywds.hxx"
 #include "unopback.hxx"
 #include "unohelp.hxx"
+#include <vcl/dibtools.hxx>
 
 using ::com::sun::star::animations::XAnimationNode;
 using ::com::sun::star::animations::XAnimationNodeSupplier;
@@ -1122,7 +1122,7 @@ Any SAL_CALL SdGenericDrawPage::getPropertyValue( const OUString& PropertyName )
                                                                   aBitmap ) )
                     {
                         SvMemoryStream aMemStream;
-                        aBitmap.GetBitmap().Write( aMemStream, sal_False, sal_False );
+                        WriteDIB(aBitmap.GetBitmap(), aMemStream, false, false);
                         uno::Sequence<sal_Int8> aSeq( (sal_Int8*)aMemStream.GetData(), aMemStream.Tell() );
                         aAny <<= aSeq;
                     }
diff --git a/sd/source/ui/view/sdview3.cxx b/sd/source/ui/view/sdview3.cxx
index 94b2abb..a0df92c 100644
--- a/sd/source/ui/view/sdview3.cxx
+++ b/sd/source/ui/view/sdview3.cxx
@@ -1209,9 +1209,9 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
     }
     else if( ( !bLink || pPickObj ) && CHECK_FORMAT_TRANS( FORMAT_BITMAP ) )
     {
-        Bitmap aBmp;
+        BitmapEx aBmpEx;
 
-        if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp ) )
+        if( aDataHelper.GetBitmapEx( FORMAT_BITMAP, aBmpEx ) )
         {
             Point aInsertPos( rPos );
 
@@ -1232,10 +1232,10 @@ sal_Bool View::InsertData( const TransferableDataHelper& rDataHelper,
             }
 
             // restrict movement to WorkArea
-            Size aImageMapSize(aBmp.GetPrefSize());
+            Size aImageMapSize(aBmpEx.GetPrefSize());
             ImpCheckInsertPos(aInsertPos, aImageMapSize, GetWorkArea());
 
-            InsertGraphic( aBmp, mnAction, aInsertPos, NULL, pImageMap );
+            InsertGraphic( aBmpEx, mnAction, aInsertPos, NULL, pImageMap );
             bReturn = sal_True;
         }
     }
diff --git a/sfx2/source/appl/fileobj.cxx b/sfx2/source/appl/fileobj.cxx
index 1083a85..b99ef48 100644
--- a/sfx2/source/appl/fileobj.cxx
+++ b/sfx2/source/appl/fileobj.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <vcl/wrkwin.hxx>
 #include <vcl/msgbox.hxx>
 #include <tools/urlobj.hxx>
@@ -41,6 +40,7 @@
 #include "sfx2/sfxresid.hxx"
 #include "fileobj.hxx"
 #include "app.hrc"
+#include <vcl/dibtools.hxx>
 
 #define FILETYPE_TEXT       1
 #define FILETYPE_GRF        2
@@ -170,9 +170,16 @@ sal_Bool SvFileObject::GetData( ::com::sun::star::uno::Any & rData,
                     break;
 
                 case  FORMAT_BITMAP:
-                    if( !aGrf.GetBitmap().IsEmpty())
-                        aMemStm << aGrf.GetBitmap();
+                {
+                    const Bitmap aBitmap(aGrf.GetBitmap());
+
+                    if(!aBitmap.IsEmpty())
+                    {
+                        WriteDIB(aBitmap, aMemStm, false, true);
+                    }
+
                     break;
+                }
 
                 default:
                     if( aGrf.GetGDIMetaFile().GetActionSize() )
diff --git a/sfx2/source/appl/linkmgr2.cxx b/sfx2/source/appl/linkmgr2.cxx
index 6c0219b..7dcccad 100644
--- a/sfx2/source/appl/linkmgr2.cxx
+++ b/sfx2/source/appl/linkmgr2.cxx
@@ -36,6 +36,7 @@
 #include <unotools/localfilehelper.hxx>
 #include <i18nlangtag/languagetag.hxx>
 #include <sfx2/request.hxx>
+#include <vcl/dibtools.hxx>
 
 #include "fileobj.hxx"
 #include "impldde.hxx"
@@ -570,7 +571,7 @@ sal_Bool LinkManager::GetGraphicFromAny( const String& rMimeType,
         case FORMAT_BITMAP:
             {
                 Bitmap aBmp;
-                aMemStm >> aBmp;
+                ReadDIB(aBmp, aMemStm, true);
                 rGrf = aBmp;
                 bRet = sal_True;
             }
diff --git a/sfx2/source/dialog/filedlghelper.cxx b/sfx2/source/dialog/filedlghelper.cxx
index a927cfe..d11cdf9 100644
--- a/sfx2/source/dialog/filedlghelper.cxx
+++ b/sfx2/source/dialog/filedlghelper.cxx
@@ -67,6 +67,7 @@
 #include <svl/eitem.hxx>
 #include <svl/intitem.hxx>
 #include <svl/stritem.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/graphicfilter.hxx>
 #include <unotools/viewoptions.hxx>
 #include <unotools/moduleoptions.hxx>
@@ -742,7 +743,7 @@ IMPL_LINK_NOARG(FileDialogHelper_Impl, TimeOutHdl_Impl)
                 // and copy it into the Any
                 SvMemoryStream aData;
 
-                aData << aBmp;
+                WriteDIB(aBmp, aData, false, true);
 
                 const Sequence < sal_Int8 > aBuffer(
                     static_cast< const sal_Int8* >(aData.GetData()),
diff --git a/sfx2/source/doc/docinf.cxx b/sfx2/source/doc/docinf.cxx
index 5dbb9dd..172cfb7 100644
--- a/sfx2/source/doc/docinf.cxx
+++ b/sfx2/source/doc/docinf.cxx
@@ -19,20 +19,18 @@
 
 
 #include <sfx2/docinf.hxx>
-
 #include <com/sun/star/beans/PropertyAttribute.hpp>
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XPropertyContainer.hpp>
 #include <com/sun/star/document/XDocumentProperties.hpp>
 #include <com/sun/star/document/XCompatWriterDocProperties.hpp>
 #include <com/sun/star/uno/Exception.hpp>
-
 #include <rtl/ustring.hxx>
 #include <tools/debug.hxx>
 #include <comphelper/string.hxx>
 #include <sot/storage.hxx>
 #include <vcl/gdimtf.hxx>
-
+#include <vcl/dibtools.hxx>
 #include "oleprops.hxx"
 // ============================================================================
 
@@ -310,7 +308,7 @@ uno::Sequence<sal_uInt8> SFX2_DLLPUBLIC convertMetaFile(GDIMetaFile* i_pThumb)
         SvMemoryStream aStream;
 // magic value 160 taken from GraphicHelper::getThumbnailFormatFromGDI_Impl()
         if( i_pThumb->CreateThumbnail( 160, aBitmap ) ) {
-            aBitmap.GetBitmap().Write( aStream, sal_False, sal_False );
+            WriteDIB(aBitmap.GetBitmap(), aStream, false, false);
             aStream.Seek(STREAM_SEEK_TO_END);
             uno::Sequence<sal_uInt8> aSeq(aStream.Tell());
             const sal_uInt8* pBlob(
diff --git a/sot/source/base/exchange.cxx b/sot/source/base/exchange.cxx
index c56cc5f..8aba238 100644
--- a/sot/source/base/exchange.cxx
+++ b/sot/source/base/exchange.cxx
@@ -202,6 +202,7 @@ namespace
             /*138 SOT_FORMATSTR_ID_STARMATH_8_TEMPLATE*/            { MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_TEMPLATE_ASCII, "Math 8 Template", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
             /*139 SOT_FORMATSTR_ID_STARBASE_8*/             { MIMETYPE_OASIS_OPENDOCUMENT_DATABASE_ASCII, "StarBase 8", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
             /*140 SOT_FORMAT_GDIMETAFILE*/                  { "application/x-openoffice-highcontrast-gdimetafile;windows_formatname=\"GDIMetaFile\"", "High Contrast GDIMetaFile", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
+            /*141 SOT_FORMATSTR_ID_PNG*/                    { "image/png", "Windows Bitmap", &::getCppuType( (const Sequence< sal_Int8 >*) 0 ) },
             };
         return &aInstance[0];
         }
diff --git a/svtools/source/graphic/graphic.cxx b/svtools/source/graphic/graphic.cxx
index a3c1751..bec4e4f 100644
--- a/svtools/source/graphic/graphic.cxx
+++ b/svtools/source/graphic/graphic.cxx
@@ -21,6 +21,7 @@
 #include <vcl/svapp.hxx>
 #include <com/sun/star/graphic/GraphicType.hpp>
 #include <com/sun/star/graphic/XGraphicTransformer.hpp>
+#include <vcl/dibtools.hxx>
 #include <vcl/graph.hxx>
 #include "graphic.hxx"
 #include <comphelper/servicehelper.hxx>
@@ -239,7 +240,8 @@ uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getDIB(  ) throw (uno::RuntimeExce
     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     {
         SvMemoryStream aMem;
-        aMem << mpGraphic->GetBitmapEx().GetBitmap();
+
+        WriteDIB(mpGraphic->GetBitmapEx().GetBitmap(), aMem, false, true);
         return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     }
     else
@@ -257,7 +259,8 @@ uno::Sequence< ::sal_Int8 > SAL_CALL Graphic::getMaskDIB(  ) throw (uno::Runtime
     if( mpGraphic && ( mpGraphic->GetType() != GRAPHIC_NONE ) )
     {
         SvMemoryStream aMem;
-        aMem << mpGraphic->GetBitmapEx().GetMask();
+
+        WriteDIB(mpGraphic->GetBitmapEx().GetMask(), aMem, false, true);
         return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
     }
     else
diff --git a/svtools/source/graphic/provider.cxx b/svtools/source/graphic/provider.cxx
index 18a68f9..9bc54b9 100644
--- a/svtools/source/graphic/provider.cxx
+++ b/svtools/source/graphic/provider.cxx
@@ -39,6 +39,7 @@
 #include "graphic.hxx"
 #include <svtools/grfmgr.hxx>
 #include "provider.hxx"
+#include <vcl/dibtools.hxx>
 
 using namespace com::sun::star;
 
@@ -244,15 +245,16 @@ uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadBitmap( const uno
     uno::Sequence< sal_Int8 > aMaskSeq( xBtm->getMaskDIB() );
     SvMemoryStream aBmpStream( aBmpSeq.getArray(), aBmpSeq.getLength(), STREAM_READ );
     Bitmap aBmp;
-    aBmpStream >> aBmp;
-
     BitmapEx aBmpEx;
 
+    ReadDIB(aBmp, aBmpStream, true);
+
     if( aMaskSeq.getLength() )
     {
         SvMemoryStream aMaskStream( aMaskSeq.getArray(), aMaskSeq.getLength(), STREAM_READ );
         Bitmap aMask;
-        aMaskStream >> aMask;
+
+        ReadDIB(aMask, aMaskStream, true);
         aBmpEx = BitmapEx( aBmp, aMask );
     }
     else
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index c1806c4..8407e19 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -55,6 +55,9 @@
 #include <svtools/transfer.hxx>
 #include <rtl/strbuf.hxx>
 #include <cstdio>
+#include <vcl/dibtools.hxx>
+#include <vcl/pngread.hxx>
+#include <vcl/pngwrite.hxx>
 
 // --------------
 // - Namespaces -
@@ -358,9 +361,9 @@ Any SAL_CALL TransferableHelper::getTransferData( const DataFlavor& rFlavor ) th
                 GetData( aSubstFlavor );
                 bDone = maAny.hasValue();
             }
-            else if( SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
-                     TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor ) &&
-                     SotExchange::GetFormatDataFlavor( FORMAT_BITMAP, aSubstFlavor ) )
+            else if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_BMP, aSubstFlavor )
+                && TransferableDataHelper::IsEqual( aSubstFlavor, rFlavor )
+                && SotExchange::GetFormatDataFlavor(FORMAT_BITMAP, aSubstFlavor))
             {
                 GetData( aSubstFlavor );
                 bDone = sal_True;
@@ -672,6 +675,7 @@ void TransferableHelper::AddFormat( const DataFlavor& rFlavor )
         if( FORMAT_BITMAP == aFlavorEx.mnSotId )
         {
             AddFormat( SOT_FORMATSTR_ID_BMP );
+            AddFormat( SOT_FORMATSTR_ID_PNG );
         }
         else if( FORMAT_GDIMETAFILE == aFlavorEx.mnSotId )
         {
@@ -765,13 +769,37 @@ sal_Bool TransferableHelper::SetString( const OUString& rString, const DataFlavo
 
 // -----------------------------------------------------------------------------
 
-sal_Bool TransferableHelper::SetBitmap( const Bitmap& rBitmap, const DataFlavor& )
+sal_Bool TransferableHelper::SetBitmapEx( const BitmapEx& rBitmapEx, const DataFlavor& rFlavor )
 {
-    if( !rBitmap.IsEmpty() )
+    if( !rBitmapEx.IsEmpty() )
     {
         SvMemoryStream aMemStm( 65535, 65535 );
 
-        aMemStm << rBitmap;
+        if(rFlavor.MimeType.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("image/png")))
+        {
+            // write a PNG
+            ::vcl::PNGWriter aPNGWriter(rBitmapEx);
+
+            aPNGWriter.Write(aMemStm);
+        }
+        else
+        {
+            const Bitmap aBitmap(rBitmapEx.GetBitmap());
+
+            if(rBitmapEx.IsTransparent())
+            {
+                const Bitmap aMask(rBitmapEx.GetAlpha().GetBitmap());
+
+                // explicitely use Bitmap::Write with bCompressed = sal_False and bFileHeader = sal_True
+                WriteDIBV5(aBitmap, aMask, aMemStm);
+            }
+            else
+            {
+                // explicitely use Bitmap::Write with bCompressed = sal_False and bFileHeader = sal_True
+                WriteDIB(aBitmap, aMemStm, false, true);
+            }
+        }
+
         maAny <<= Sequence< sal_Int8 >( reinterpret_cast< const sal_Int8* >( aMemStm.GetData() ), aMemStm.Seek( STREAM_SEEK_TO_END ) );
     }
 
@@ -1358,7 +1386,7 @@ void TransferableDataHelper::FillDataFlavorExVector( const Sequence< DataFlavor
             rDataFlavorExVector.push_back( aFlavorEx );
 
             // add additional formats for special mime types
-            if( SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId )
+            if(SOT_FORMATSTR_ID_BMP == aFlavorEx.mnSotId || SOT_FORMATSTR_ID_PNG == aFlavorEx.mnSotId)
             {
                 if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavorEx ) )
                 {
@@ -1663,24 +1691,74 @@ sal_Bool TransferableDataHelper::GetString( const DataFlavor& rFlavor, OUString&
 
 // -----------------------------------------------------------------------------
 
-sal_Bool TransferableDataHelper::GetBitmap( SotFormatStringId nFormat, Bitmap& rBmp )
+sal_Bool TransferableDataHelper::GetBitmapEx( SotFormatStringId nFormat, BitmapEx& rBmpEx )
 {
+    if(FORMAT_BITMAP == nFormat)
+    {
+        // try to get PNG first
+        DataFlavor aFlavor;
+
+        if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor))
+        {
+            if(GetBitmapEx(aFlavor, rBmpEx))
+            {
+                return true;
+            }
+        }
+    }
+
     DataFlavor aFlavor;
-    return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmap( aFlavor, rBmp ) );
+    return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetBitmapEx( aFlavor, rBmpEx ) );
 }
 
 // -----------------------------------------------------------------------------
 
-sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& rBmp )
+sal_Bool TransferableDataHelper::GetBitmapEx( const DataFlavor& rFlavor, BitmapEx& rBmpEx )
 {
     SotStorageStreamRef xStm;
-    DataFlavor          aSubstFlavor;
-    sal_Bool            bRet = GetSotStorageStream( rFlavor, xStm );
+    DataFlavor aSubstFlavor;
+    bool bRet(GetSotStorageStream(rFlavor, xStm));
 
-    if( bRet )
+    if(!bRet && HasFormat(SOT_FORMATSTR_ID_PNG) && SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aSubstFlavor))
     {
-        *xStm >> rBmp;
-        bRet = ( xStm->GetError() == ERRCODE_NONE );
+        // when no direct success, try if PNG is available
+        bRet = GetSotStorageStream(aSubstFlavor, xStm);
+    }
+
+    if(!bRet && HasFormat(SOT_FORMATSTR_ID_BMP) && SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_BMP, aSubstFlavor))
+    {
+        // when no direct success, try if BMP is available
+        bRet = GetSotStorageStream(aSubstFlavor, xStm);
+    }
+
+    if(bRet)
+    {
+        if(rFlavor.MimeType.equalsIgnoreAsciiCase(::rtl::OUString::createFromAscii("image/png")))
+        {
+            // it's a PNG, import to BitmapEx
+            ::vcl::PNGReader aPNGReader(*xStm);
+
+            rBmpEx = aPNGReader.Read();
+        }
+        else
+        {
+            Bitmap aBitmap;
+            Bitmap aMask;
+
+            // explicitely use Bitmap::Read with bFileHeader = sal_True
+            ReadDIBV5(aBitmap, aMask, *xStm);
+
+            if(aMask.IsEmpty())
+            {
+                rBmpEx = aBitmap;
+            }
+            else
+            {
+                rBmpEx = BitmapEx(aBitmap, aMask);
+            }
+        }
+
+        bRet = (ERRCODE_NONE == xStm->GetError());
 
         /* SJ: #110748# At the moment we are having problems with DDB inserted as DIB. The
            problem is, that some graphics are inserted much too big because the nXPelsPerMeter
@@ -1691,28 +1769,22 @@ sal_Bool TransferableDataHelper::GetBitmap( const DataFlavor& rFlavor, Bitmap& r
            The following code should be removed if DDBs and DIBs are supported via clipboard
            properly.
         */
-        if ( bRet )
+        if(bRet)
         {
-            MapMode aMapMode = rBmp.GetPrefMapMode();
-            if ( aMapMode.GetMapUnit() != MAP_PIXEL )
+            const MapMode aMapMode(rBmpEx.GetPrefMapMode());
+
+            if(MAP_PIXEL != aMapMode.GetMapUnit())
             {
-                Size aSize = OutputDevice::LogicToLogic( rBmp.GetPrefSize(), aMapMode, MAP_100TH_MM );
-                if ( ( aSize.Width() > 5000 ) || ( aSize.Height() > 5000 ) )
-                    rBmp.SetPrefMapMode( MAP_PIXEL );
+                const Size aSize(OutputDevice::LogicToLogic(rBmpEx.GetPrefSize(), aMapMode, MAP_100TH_MM));
+
+                if((aSize.Width() > 5000) || (aSize.Height() > 5000))
+                {
+                    rBmpEx.SetPrefMapMode(MAP_PIXEL);
+                }
             }
         }
     }
 
-    if( !bRet &&
-        HasFormat( SOT_FORMATSTR_ID_BMP ) &&
-        SotExchange::GetFormatDataFlavor( SOT_FORMATSTR_ID_BMP, aSubstFlavor ) &&
-        GetSotStorageStream( aSubstFlavor, xStm ) )
-    {
-        xStm->ResetError();
-        *xStm >> rBmp;
-        bRet = ( xStm->GetError() == ERRCODE_NONE );
-    }
-
     return bRet;
 }
 
@@ -1773,6 +1845,20 @@ sal_Bool TransferableDataHelper::GetGDIMetaFile( const DataFlavor& rFlavor, GDIM
 
 sal_Bool TransferableDataHelper::GetGraphic( SotFormatStringId nFormat, Graphic& rGraphic )
 {
+    if(FORMAT_BITMAP == nFormat)
+    {
+        // try to get PNG first
+        DataFlavor aFlavor;
+
+        if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor))
+        {
+            if(GetGraphic(aFlavor, rGraphic))
+            {
+                return true;
+            }
+        }
+    }
+
     DataFlavor aFlavor;
     return( SotExchange::GetFormatDataFlavor( nFormat, aFlavor ) && GetGraphic( aFlavor, rGraphic ) );
 }
@@ -1784,13 +1870,22 @@ sal_Bool TransferableDataHelper::GetGraphic( const ::com::sun::star::datatransfe
     DataFlavor  aFlavor;
     sal_Bool    bRet = sal_False;
 
-    if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
+    if(SotExchange::GetFormatDataFlavor(SOT_FORMATSTR_ID_PNG, aFlavor) &&
+        TransferableDataHelper::IsEqual(aFlavor, rFlavor))
+    {
+        // try to get PNG first
+        BitmapEx aBmpEx;
+
+        if( ( bRet = GetBitmapEx( aFlavor, aBmpEx ) ) == sal_True )
+            rGraphic = aBmpEx;
+    }
+    else if(SotExchange::GetFormatDataFlavor( SOT_FORMAT_BITMAP, aFlavor ) &&
         TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
     {
-        Bitmap aBmp;
+        BitmapEx aBmpEx;
 
-        if( ( bRet = GetBitmap( aFlavor, aBmp ) ) == sal_True )
-            rGraphic = aBmp;
+        if( ( bRet = GetBitmapEx( aFlavor, aBmpEx ) ) == sal_True )
+            rGraphic = aBmpEx;
     }
     else if( SotExchange::GetFormatDataFlavor( SOT_FORMAT_GDIMETAFILE, aFlavor ) &&
              TransferableDataHelper::IsEqual( aFlavor, rFlavor ) )
diff --git a/svx/source/gallery2/galmisc.cxx b/svx/source/gallery2/galmisc.cxx
index 499ab34..06c8d15 100644
--- a/svx/source/gallery2/galmisc.cxx
+++ b/svx/source/gallery2/galmisc.cxx
@@ -590,7 +590,7 @@ sal_Bool GalleryTransferable::GetData( const datatransfer::DataFlavor& rFlavor )
     }
     else if( ( FORMAT_BITMAP == nFormat ) && mpGraphicObject )
     {
-        bRet = SetBitmap( mpGraphicObject->GetGraphic().GetBitmap(), rFlavor );
+        bRet = SetBitmapEx( mpGraphicObject->GetGraphic().GetBitmapEx(), rFlavor );
     }
 
     return bRet;
diff --git a/svx/source/gallery2/galobj.cxx b/svx/source/gallery2/galobj.cxx
index 573dcf6..eb1b6e4 100644
--- a/svx/source/gallery2/galobj.cxx
+++ b/svx/source/gallery2/galobj.cxx
@@ -21,11 +21,9 @@
 #include <com/sun/star/lang/XUnoTunnel.hpp>
 #include <sfx2/objsh.hxx>
 #include <sfx2/docfac.hxx>
-
 #include <comphelper/classids.hxx>
 #include <comphelper/string.hxx>
 #include <unotools/pathoptions.hxx>
-
 #include <tools/rcid.h>
 #include <tools/vcompat.hxx>
 #include <tools/helpers.hxx>
@@ -38,7 +36,7 @@
 #include "svx/galmisc.hxx"
 #include "galobj.hxx"
 #include <vcl/svapp.hxx>
-
+#include <vcl/dibtools.hxx>
 #include "gallerydrawmodel.hxx"
 
 using namespace ::com::sun::star;
@@ -150,7 +148,7 @@ void SgaObject::WriteData( SvStream& rOut, const String& rDestDir ) const
         rOut.SetCompressMode( COMPRESSMODE_ZBITMAP );
         rOut.SetVersion( SOFFICE_FILEFORMAT_50 );
 
-        rOut << aThumbBmp;
+        WriteDIBBitmapEx(aThumbBmp, rOut);
 
         rOut.SetVersion( nOldVersion );
         rOut.SetCompressMode( nOldCompressMode );
@@ -173,9 +171,13 @@ void SgaObject::ReadData(SvStream& rIn, sal_uInt16& rReadVersion )
     rIn >> nTmp32 >> nTmp16 >> rReadVersion >> nTmp16 >> bIsThumbBmp;
 
     if( bIsThumbBmp )
-        rIn >> aThumbBmp;
+    {
+        ReadDIBBitmapEx(aThumbBmp, rIn);
+    }
     else
+    {
         rIn >> aThumbMtf;
+    }
 
     OUString aTmpStr = read_lenPrefixed_uInt8s_ToOUString<sal_uInt16>(rIn, RTL_TEXTENCODING_UTF8);
     aURL = INetURLObject(aTmpStr);
diff --git a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
index 47d76f8..d502094 100644
--- a/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
+++ b/svx/source/sdr/overlay/overlaymanagerbuffered.cxx
@@ -26,6 +26,7 @@
 #include <tools/stream.hxx>
 #include <basegfx/matrix/b2dhommatrix.hxx>
 #include <vcl/cursor.hxx>
+#include <vcl/dibtools.hxx>
 
 //////////////////////////////////////////////////////////////////////////////
 
diff --git a/svx/source/xoutdev/_xoutbmp.cxx b/svx/source/xoutdev/_xoutbmp.cxx
index 33e36ee..535d6b3 100644
--- a/svx/source/xoutdev/_xoutbmp.cxx
+++ b/svx/source/xoutdev/_xoutbmp.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <sot/factory.hxx>
 #include <tools/poly.hxx>
 #include <vcl/bmpacc.hxx>
@@ -27,6 +26,7 @@
 #include <sfx2/docfile.hxx>
 #include <sfx2/app.hxx>
 #include "svx/xoutbmp.hxx"
+#include <vcl/dibtools.hxx>
 #include <vcl/FilterConfigItem.hxx>
 #include <vcl/graphicfilter.hxx>
 
@@ -363,8 +363,8 @@ Bitmap XOutBitmap::DetectEdges( const Bitmap& rBmp, const sal_uInt8 cThreshold )
                 const long          nHeight = aSize.Height();
                 const long          nHeight2 = nHeight - 2L;
                 const long          lThres2 = (long) cThreshold * cThreshold;
-                const sal_uInt8 nWhitePalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_WHITE ) );
-                const sal_uInt8 nBlackPalIdx = pWriteAcc->GetBestPaletteIndex( Color( COL_BLACK ) );
+                const sal_uInt8 nWhitePalIdx(static_cast< sal_uInt8 >(pWriteAcc->GetBestPaletteIndex(Color(COL_WHITE))));
+                const sal_uInt8 nBlackPalIdx(static_cast< sal_uInt8 >(pWriteAcc->GetBestPaletteIndex(Color(COL_BLACK))));
                 long                nSum1;
                 long                nSum2;
                 long                lGray;
diff --git a/svx/source/xoutdev/xattrbmp.cxx b/svx/source/xoutdev/xattrbmp.cxx
index 8525591..462bae6 100644
--- a/svx/source/xoutdev/xattrbmp.cxx
+++ b/svx/source/xoutdev/xattrbmp.cxx
@@ -38,6 +38,7 @@
 #include <com/sun/star/beans/PropertyValue.hpp>
 #include <vcl/salbtype.hxx>
 #include <vcl/bmpacc.hxx>
+#include <vcl/dibtools.hxx>
 
 using namespace ::com::sun::star;
 
@@ -357,7 +358,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
             // Behandlung der alten Bitmaps
             Bitmap aBmp;
 
-            rIn >> aBmp;
+            ReadDIB(aBmp, rIn, true);
             maGraphicObject = Graphic(aBmp);
         }
         else if(1 == nVer)
@@ -371,7 +372,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
             {
                 Bitmap aBmp;
 
-                rIn >> aBmp;
+                ReadDIB(aBmp, rIn, true);
                 maGraphicObject = Graphic(aBmp);
             }
             else if(XBITMAP_8X8 == iTmp)
@@ -398,7 +399,7 @@ XFillBitmapItem::XFillBitmapItem(SvStream& rIn, sal_uInt16 nVer)
         {
             BitmapEx aBmpEx;
 
-            rIn >> aBmpEx;
+            ReadDIBBitmapEx(aBmpEx, rIn);
             maGraphicObject = Graphic(aBmpEx);
         }
     }
@@ -442,7 +443,7 @@ SvStream& XFillBitmapItem::Store( SvStream& rOut, sal_uInt16 nItemVersion ) cons
 
     if(!IsIndex())
     {
-        rOut << maGraphicObject.GetGraphic().GetBitmapEx();
+        WriteDIBBitmapEx(maGraphicObject.GetGraphic().GetBitmapEx(), rOut);
     }
 
     return rOut;
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 6dabfbc..5a26af2 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <com/sun/star/accessibility/XAccessible.hpp>
-
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/progress.hxx>
 #include <svx/srchdlg.hxx>
@@ -61,10 +60,9 @@
 
 #include "../../ui/inc/view.hxx"
 #include <PostItMgr.hxx>
+#include <vcl/dibtools.hxx>
 #include <vcl/virdev.hxx>
-
 #include <vcl/svapp.hxx>
-
 #include <svx/sdrpaintwindow.hxx>
 
 sal_Bool ViewShell::mbLstAct = sal_False;
diff --git a/sw/source/filter/ww1/w1filter.cxx b/sw/source/filter/ww1/w1filter.cxx
index c248348..ce1c7d0 100644
--- a/sw/source/filter/ww1/w1filter.cxx
+++ b/sw/source/filter/ww1/w1filter.cxx
@@ -18,7 +18,6 @@
  */
 
 #include <hintids.hxx>
-
 #include <tools/solar.h>
 #include <comphelper/string.hxx>
 #include <editeng/paperinf.hxx>
@@ -54,17 +53,14 @@
 #include <section.hxx>          // class SwSection
 #include <fltini.hxx>
 #include <w1par.hxx>
-
 #include <docsh.hxx>
 #include <swerror.h>
 #include <mdiexp.hxx>
 #include <statstr.hrc>
-#if OSL_DEBUG_LEVEL > 0
 #include <stdio.h>
-#endif
-
 #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
 #include <com/sun/star/document/XDocumentProperties.hpp>
+#include <vcl/dibtools.hxx>
 
 #define MAX_FIELDLEN 64000
 
@@ -1909,7 +1905,7 @@ void Ww1Picture::Out(Ww1Shell& rOut, Ww1Manager& /*rMan*/)
         SvMemoryStream aOut(nSiz, 8192);
         WriteBmp(aOut);
         Bitmap aBmp;
-        aOut >> aBmp;
+        ReadDIB(aBmp, aOut, true);
         pGraphic = new Graphic(aBmp);
     }
     default:
diff --git a/sw/source/ui/dochdl/swdtflvr.cxx b/sw/source/ui/dochdl/swdtflvr.cxx
index 31e0fa6..03efaa1 100644
--- a/sw/source/ui/dochdl/swdtflvr.cxx
+++ b/sw/source/ui/dochdl/swdtflvr.cxx
@@ -549,11 +549,10 @@ sal_Bool SwTransferable::GetData( const DataFlavor& rFlavor )
                 bOK = SetGDIMetaFile( pClpGraphic->GetGDIMetaFile(), rFlavor );
             break;
         case SOT_FORMAT_BITMAP:
+        case SOT_FORMATSTR_ID_PNG:
             // Neither pClpBitmap nor pClpGraphic are necessarily set
             if( (eBufferType & TRNSFR_GRAPHIC) && (pClpBitmap != 0 || pClpGraphic != 0))
-                bOK = SetBitmap( (pClpBitmap ? pClpBitmap
-                                             : pClpGraphic)->GetBitmap(),
-                                 rFlavor );
+                bOK = SetBitmapEx( (pClpBitmap ? pClpBitmap : pClpGraphic)->GetBitmapEx(), rFlavor );
             break;
 
         case SOT_FORMATSTR_ID_SVIM:
@@ -800,6 +799,7 @@ int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
         if( pGrf && pGrf->IsSupportedGraphic() )
         {
             AddFormat( FORMAT_GDIMETAFILE );
+            AddFormat( SOT_FORMATSTR_ID_PNG );
             AddFormat( FORMAT_BITMAP );
         }
         eBufferType = TRNSFR_GRAPHIC;
@@ -905,6 +905,7 @@ int SwTransferable::PrepareForCopy( sal_Bool bIsCut )
             if ( nSelection & nsSelectionType::SEL_DRW )
             {
                 AddFormat( FORMAT_GDIMETAFILE );
+                AddFormat( SOT_FORMATSTR_ID_PNG );
                 AddFormat( FORMAT_BITMAP );
             }
             eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
@@ -2889,6 +2890,7 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
         if ( pGrf && pGrf->IsSupportedGraphic() )
         {
             AddFormat( FORMAT_GDIMETAFILE );
+            AddFormat( SOT_FORMATSTR_ID_PNG );
             AddFormat( FORMAT_BITMAP );
         }
         eBufferType = TRNSFR_GRAPHIC;
@@ -2937,6 +2939,7 @@ void SwTransferable::SetDataForDragAndDrop( const Point& rSttPos )
             if ( nSelection & nsSelectionType::SEL_DRW )
             {
                 AddFormat( FORMAT_GDIMETAFILE );
+                AddFormat( SOT_FORMATSTR_ID_PNG );
                 AddFormat( FORMAT_BITMAP );
             }
             eBufferType = (TransferBufferType)( TRNSFR_GRAPHIC | eBufferType );
diff --git a/toolkit/source/awt/vclxbitmap.cxx b/toolkit/source/awt/vclxbitmap.cxx
index fd9b5ae..7047f12 100644
--- a/toolkit/source/awt/vclxbitmap.cxx
+++ b/toolkit/source/awt/vclxbitmap.cxx
@@ -22,6 +22,7 @@
 #include <cppuhelper/typeprovider.hxx>
 #include <tools/stream.hxx>
 #include <rtl/uuid.h>
+#include <vcl/dibtools.hxx>
 
 //  ----------------------------------------------------
 //  class VCLXBitmap
@@ -62,7 +63,7 @@ IMPL_XTYPEPROVIDER_END
     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
 
     SvMemoryStream aMem;
-    aMem << maBitmap.GetBitmap();
+    WriteDIB(maBitmap.GetBitmap(), aMem, false, true);
     return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
 }
 
@@ -71,11 +72,8 @@ IMPL_XTYPEPROVIDER_END
     ::osl::Guard< ::osl::Mutex > aGuard( GetMutex() );
 
     SvMemoryStream aMem;
-    aMem << maBitmap.GetMask();
+    WriteDIB(maBitmap.GetMask(), aMem, false, true);
     return ::com::sun::star::uno::Sequence<sal_Int8>( (sal_Int8*) aMem.GetData(), aMem.Tell() );
 }
 
-
-
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/toolkit/source/helper/vclunohelper.cxx b/toolkit/source/helper/vclunohelper.cxx
index 3d275c1..5767b27 100644
--- a/toolkit/source/helper/vclunohelper.cxx
+++ b/toolkit/source/helper/vclunohelper.cxx
@@ -17,7 +17,6 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-
 #include <tools/stream.hxx>
 #include <vcl/bitmap.hxx>
 #include <vcl/window.hxx>
@@ -36,9 +35,7 @@
 #include <com/sun/star/awt/MouseButton.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
 #include <com/sun/star/embed/EmbedMapUnits.hpp>
-
 #include <com/sun/star/graphic/XGraphic.hpp>
-
 #include <toolkit/helper/vclunohelper.hxx>
 #include <toolkit/helper/convert.hxx>
 #include <toolkit/awt/vclxbitmap.hxx>
@@ -49,13 +46,13 @@
 #include <toolkit/awt/vclxfont.hxx>
 #include <toolkit/controls/unocontrolcontainer.hxx>
 #include <toolkit/controls/unocontrolcontainermodel.hxx>
-
 #include <vcl/graph.hxx>
 #include <comphelper/processfactory.hxx>
 
 #include <com/sun/star/awt/Toolkit.hpp>
 #include <com/sun/star/awt/Size.hpp>
 #include <com/sun/star/awt/Point.hpp>
+#include <vcl/dibtools.hxx>
 
 using namespace ::com::sun::star;
 
@@ -91,12 +88,12 @@ BitmapEx VCLUnoHelper::GetBitmap( const ::com::sun::star::uno::Reference< ::com:
             {
                 ::com::sun::star::uno::Sequence<sal_Int8> aBytes = rxBitmap->getDIB();
                 SvMemoryStream aMem( (char*) aBytes.getArray(), aBytes.getLength(), STREAM_READ );
-                aMem >> aDIB;
+                ReadDIB(aDIB, aMem, true);
             }
             {
                 ::com::sun::star::uno::Sequence<sal_Int8> aBytes = rxBitmap->getMaskDIB();
                 SvMemoryStream aMem( (char*) aBytes.getArray(), aBytes.getLength(), STREAM_READ );
-                aMem >> aMask;
+                ReadDIB(aMask, aMem, true);
             }
             aBmp = BitmapEx( aDIB, aMask );
         }
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index 45bdcfd..79d5326 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -189,7 +189,6 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/gdi/alpha \
     vcl/source/gdi/animate \
     vcl/source/gdi/base14 \
-    vcl/source/gdi/bitmap2 \
     vcl/source/gdi/bitmap3 \
     vcl/source/gdi/bitmap4 \
     vcl/source/gdi/bitmap \
@@ -202,6 +201,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
     vcl/source/gdi/configsettings \
     vcl/source/gdi/cvtgrf \
     vcl/source/gdi/cvtsvm \
+    vcl/source/gdi/dibtools \
     vcl/source/gdi/embeddedfontshelper \
     vcl/source/gdi/extoutdevdata \
     vcl/source/gdi/font \
diff --git a/vcl/aqua/source/dtrans/DataFlavorMapping.cxx b/vcl/aqua/source/dtrans/DataFlavorMapping.cxx
index d61d09b..6381e4d 100644
--- a/vcl/aqua/source/dtrans/DataFlavorMapping.cxx
+++ b/vcl/aqua/source/dtrans/DataFlavorMapping.cxx
@@ -124,8 +124,8 @@ namespace // private
     {
       { NSStringPboardType, "text/plain;charset=utf-16", "Unicode Text (UTF-16)", true },
       { NSRTFPboardType, "text/richtext", "Rich Text Format", false },
-      { NSTIFFPboardType, "image/bmp", "Windows Bitmap", false },
-      { NSPICTPboardType, "image/bmp", "Windows Bitmap", false },
+      { NSTIFFPboardType, "image/png", "Portable Network Graphics", false },
+      { NSPICTPboardType, "image/png", "Portable Network Graphics", false },
       { NSHTMLPboardType, "text/html", "Plain Html", false },
       { NSFilenamesPboardType, "application/x-openoffice-filelist;windows_formatname=\"FileList\"", "FileList", false },
       { PBTYPE_SESX, FLAVOR_SESX, "Star Embed Source (XML)", false },
@@ -370,73 +370,65 @@ Any HTMLFormatDataProvider::getOOoData()
 
 //###########################
 
-class BMPDataProvider : public DataProviderBaseImpl
+class PNGDataProvider : public DataProviderBaseImpl
 {
     NSBitmapImageFileType meImageType;
 public:
-  BMPDataProvider(const Any& data, NSBitmapImageFileType eImageType );
+    PNGDataProvider( const Any&, NSBitmapImageFileType);
 
-  BMPDataProvider(NSData* data, NSBitmapImageFileType eImageType);
+    PNGDataProvider( NSData*, NSBitmapImageFileType);
 
-  virtual NSData* getSystemData();
+    virtual NSData* getSystemData();
 
-  virtual Any getOOoData();
+    virtual Any getOOoData();
 };
 
-BMPDataProvider::BMPDataProvider(const Any& data, NSBitmapImageFileType eImageType) :
+PNGDataProvider::PNGDataProvider( const Any& data, NSBitmapImageFileType eImageType) :
   DataProviderBaseImpl(data),
   meImageType( eImageType )
 {
 }
 
-BMPDataProvider::BMPDataProvider(NSData* data, NSBitmapImageFileType eImageType) :
+PNGDataProvider::PNGDataProvider( NSData* data, NSBitmapImageFileType eImageType) :
   DataProviderBaseImpl(data),
   meImageType( eImageType )
 {
 }
 
-NSData* BMPDataProvider::getSystemData()
+NSData* PNGDataProvider::getSystemData()
 {
-  Sequence<sal_Int8> bmpData;
-  mData >>= bmpData;
+    Sequence<sal_Int8> pngData;
+    mData >>= pngData;
 
-  Sequence<sal_Int8> pictData;
-  NSData* sysData = NULL;
-
-  if (BMPToImage(bmpData, pictData, meImageType))
-    {
-      sysData = [NSData dataWithBytes: pictData.getArray() length: pictData.getLength()];
-    }
+    Sequence<sal_Int8> imgData;
+    NSData* sysData = NULL;
+    if( PNGToImage( pngData, imgData, meImageType))
+        sysData = [NSData dataWithBytes: imgData.getArray() length: imgData.getLength()];
 
-  return sysData;
+    return sysData;
 }
 
-/* At the moment the OOo 'PCT' filter is not good enough to be used
-   and there is no flavor defined for exchanging 'PCT' with OOo so
-   we will at the moment convert 'PCT' to a Windows BMP and provide
-   this to OOo
+/* The AOO 'PCT' filter is not yet good enough to be used
+   and there is no flavor defined for exchanging 'PCT' with AOO
+   so we convert 'PCT' to a PNG and provide this to AOO
 */
-Any BMPDataProvider::getOOoData()
+Any PNGDataProvider::getOOoData()
 {
-  Any oOOData;
+    Any oOOData;
 
-  if (mSystemData)
+    if( mSystemData)
     {
-      unsigned int flavorDataLength = [mSystemData length];
-      Sequence<sal_Int8> pictData(flavorDataLength);
+        const unsigned int flavorDataLength = [mSystemData length];
+        Sequence<sal_Int8> imgData( flavorDataLength);
+        memcpy( imgData.getArray(), [mSystemData bytes], flavorDataLength);
 
-      memcpy(pictData.getArray(), [mSystemData bytes], flavorDataLength);
-
-      Sequence<sal_Int8> bmpData;
-
-      if (ImageToBMP(pictData, bmpData, meImageType))
-        {
-          oOOData = makeAny(bmpData);
-        }
+        Sequence<sal_Int8> pngData;
+        if( ImageToPNG( imgData, pngData, meImageType))
+            oOOData = makeAny( pngData);
     }
-  else
+    else
     {
-      oOOData = mData;
+        oOOData = mData;
     }
 
   return oOOData;
@@ -612,11 +604,11 @@ DataProviderPtr_t DataFlavorMapper::getDataProvider(NSString* systemFlavor, Refe
           */
           if ([systemFlavor caseInsensitiveCompare: NSPICTPboardType] == NSOrderedSame)
             {
-              dp = DataProviderPtr_t(new BMPDataProvider(data, PICTImageFileType));
+              dp = DataProviderPtr_t( new PNGDataProvider( data, PICTImageFileType));
             }
           else if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame)
             {
-              dp = DataProviderPtr_t(new BMPDataProvider(data, NSTIFFFileType));
+              dp = DataProviderPtr_t( new PNGDataProvider( data, NSTIFFFileType));
             }
           else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame)
             {
@@ -663,11 +655,11 @@ DataProviderPtr_t DataFlavorMapper::getDataProvider(const NSString* systemFlavor
     }
   else if ([systemFlavor caseInsensitiveCompare: NSPICTPboardType] == NSOrderedSame)
     {
-      dp = DataProviderPtr_t(new BMPDataProvider(systemData, PICTImageFileType));
+      dp = DataProviderPtr_t( new PNGDataProvider(systemData, PICTImageFileType));
     }
   else if ([systemFlavor caseInsensitiveCompare: NSTIFFPboardType] == NSOrderedSame)
     {
-      dp = DataProviderPtr_t(new BMPDataProvider(systemData, NSTIFFFileType));
+      dp = DataProviderPtr_t( new PNGDataProvider(systemData, NSTIFFFileType));
     }
   else if ([systemFlavor caseInsensitiveCompare: NSFilenamesPboardType] == NSOrderedSame)
     {
diff --git a/vcl/aqua/source/dtrans/OSXTransferable.cxx b/vcl/aqua/source/dtrans/OSXTransferable.cxx
index c71bfc4..89e5c30 100644
--- a/vcl/aqua/source/dtrans/OSXTransferable.cxx
+++ b/vcl/aqua/source/dtrans/OSXTransferable.cxx
@@ -74,7 +74,7 @@ Any SAL_CALL OSXTransferable::getTransferData( const DataFlavor& aFlavor )
     }
 
   NSString* sysFormat =
-      (aFlavor.MimeType.startsWith("image/bmp"))
+      (aFlavor.MimeType.startsWith("image/png"))
       ? mDataFlavorMapper->openOfficeImageToSystemFlavor( mPasteboard )
       : mDataFlavorMapper->openOfficeToSystemFlavor(aFlavor);
   DataProviderPtr_t dp;
diff --git a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx
index 0bbb33b..61cb721 100644
--- a/vcl/aqua/source/dtrans/PictToBmpFlt.cxx
+++ b/vcl/aqua/source/dtrans/PictToBmpFlt.cxx
@@ -33,58 +33,49 @@
 
 #include "PictToBmpFlt.hxx"
 
-bool PICTtoBMP(com::sun::star::uno::Sequence<sal_Int8>& aPict,
-               com::sun::star::uno::Sequence<sal_Int8>& aBmp)
+bool PICTtoPNG( com::sun::star::uno::Sequence<sal_Int8>& rPictData,
+            com::sun::star::uno::Sequence<sal_Int8>& rPngData)
 {
-
-  bool result = false;
-
 #ifdef __LP64__
-  // FIXME
-  (void) aPict;
-  (void) aBmp;
+    // FIXME
+    (void) rPictData;
+    (void) rPngData;
+    return false;
 #else
-  ComponentInstance bmpExporter;
-  if (OpenADefaultComponent(GraphicsExporterComponentType,
-                            kQTFileTypeBMP,
-                            &bmpExporter) != noErr)
-    {
-      return result;
-    }
-
-  Handle hPict;
-  if (PtrToHand(aPict.getArray(), &hPict, aPict.getLength()) != noErr)
+    ComponentInstance pngExporter = NULL;
+    if( OpenADefaultComponent( GraphicsExporterComponentType, kQTFileTypePNG, &pngExporter) != noErr)
+        return false;
+
+    Handle hPict = NULL;
+    if( PtrToHand( rPictData.getArray(), &hPict, rPictData.getLength()) != noErr)
+        hPict = NULL;
+
+    Handle hPng = NULL;
+    if( hPict && GraphicsExportSetInputPicture( pngExporter, (PicHandle)hPict) == noErr)
+        hPng = NewHandleClear(0);
+
+    size_t nPngSize = 0;
+    if( hPng
+    && (GraphicsExportSetOutputHandle( pngExporter, hPng) == noErr)
+    && (GraphicsExportDoExport( pngExporter, NULL) == noErr))
     {
-      return result;
-    }
+        nPngSize = GetHandleSize( hPng);
+        rPngData.realloc( nPngSize);
 
-  Handle hBmp;
-  if ((GraphicsExportSetInputPicture(bmpExporter, (PicHandle)hPict) != noErr) ||
-      ((hBmp = NewHandleClear(0)) == NULL))
-    {
-      CloseComponent(bmpExporter);
-      DisposeHandle(hPict);
-      return result;
+        HLock( hPng);
+        rtl_copyMemory( rPngData.getArray(), ((sal_Int8*)*hPng), nPngSize);
+        HUnlock( hPng);
     }
 
-  if ((GraphicsExportSetOutputHandle(bmpExporter, hBmp) == noErr) &&
-      (GraphicsExportDoExport(bmpExporter, NULL) == noErr))
-    {
-      size_t sz = GetHandleSize(hBmp);
-      aBmp.realloc(sz);
-
-      HLock(hBmp);
-      memcpy(aBmp.getArray(), ((sal_Int8*)*hBmp), sz);
-      HUnlock(hBmp);
-
-      result = true;
-    }
+    if( hPict)
+        DisposeHandle( hPict);
+    if( hPng)
+        DisposeHandle( hPng);
+    if( pngExporter)
+        CloseComponent( pngExporter);
 
-  DisposeHandle(hPict);
-  DisposeHandle(hBmp);
-  CloseComponent(bmpExporter);
+    return (nPngSize > 0);
 #endif
-  return result;
 }
 
 #if MACOSX_SDK_VERSION >= 1070
@@ -102,118 +93,99 @@ extern void KillPicture(PicHandle myPicture);
 
 #endif
 
-bool BMPtoPICT(com::sun::star::uno::Sequence<sal_Int8>& aBmp,
-               com::sun::star::uno::Sequence<sal_Int8>& aPict)
+bool PNGtoPICT( com::sun::star::uno::Sequence<sal_Int8>& rPngData,
+               com::sun::star::uno::Sequence<sal_Int8>& rPictData)
 {
-  bool result = false;
-
-  Handle hBmp;
-  if ((PtrToHand(aBmp.getArray(), &hBmp, aBmp.getLength()) != noErr))
-    {
-      return result;
-    }
-
 #ifdef __LP64__
-  // FIXME
-  (void) aPict;
+    // FIXME
+    (void) rPngData;
+    (void) rPictData;
+    return false;
 #else
-  ComponentInstance pictExporter;
-
-  if (OpenADefaultComponent(GraphicsImporterComponentType,
-                            kQTFileTypeBMP,
-                            &pictExporter) != noErr)
+    ComponentInstance pictExporter;
+    if( OpenADefaultComponent( GraphicsImporterComponentType, kQTFileTypePNG, &pictExporter) != noErr)
+        return false;
+
+    Handle hPng = NULL;
+    if( PtrToHand( rPngData.getArray(), &hPng, rPngData.getLength()) != noErr)
+        hPng = NULL;
+
+    size_t nPictSize = 0;
+    PicHandle hPict = NULL;
+    if( hPng
+    && (GraphicsImportSetDataHandle( pictExporter, hPng) == noErr)
+    && (GraphicsImportGetAsPicture( pictExporter, &hPict) == noErr))
     {
-      DisposeHandle(hBmp);
-      return result;
-    }
-
-  if (GraphicsImportSetDataHandle(pictExporter, hBmp) != noErr)
-    {
-      DisposeHandle(hBmp);
-      CloseComponent(pictExporter);
-      return result;
-    }
-
-  PicHandle hPict;
-  if (GraphicsImportGetAsPicture(pictExporter, &hPict) == noErr)
-    {
-      size_t sz = GetHandleSize((Handle)hPict);
-      aPict.realloc(sz);
-
-      HLock((Handle)hPict);
-      memcpy(aPict.getArray(), ((sal_Int8*)*hPict), sz);
-      HUnlock((Handle)hPict);
-
-      // Release the data associated with the picture
-      // Note: This function is deprecated in Mac OS X
-      // 10.4.
+        nPictSize = GetHandleSize( (Handle)hPict);
+        rPictData.realloc( nPictSize);
 
-      KillPicture(hPict);
+        HLock( (Handle)hPict);
+        rtl_copyMemory( rPictData.getArray(), ((sal_Int8*)*hPict), nPictSize);
+        HUnlock( (Handle)hPict);
 
-      result = true;
+        // Release the data associated with the picture
+        // Note: This function is deprecated in Mac OSX 10.4
+        KillPicture( hPict);
     }
 
-  DisposeHandle(hBmp);
-  CloseComponent(pictExporter);
+    if( hPng)
+        DisposeHandle( hPng);
+    if( pictExporter)
+        CloseComponent( pictExporter);
+
+    return (nPictSize > 512);
 #endif
-  return result;
 }
 
-bool ImageToBMP( com::sun::star::uno::Sequence<sal_Int8>& aPict,
-                 com::sun::star::uno::Sequence<sal_Int8>& aBmp,
+bool ImageToPNG( com::sun::star::uno::Sequence<sal_Int8>& rImgData,
+                 com::sun::star::uno::Sequence<sal_Int8>& rPngData,
                  NSBitmapImageFileType eInFormat)
 {
-    if( eInFormat == PICTImageFileType )
-        return PICTtoBMP( aPict, aBmp );
+    if( eInFormat == PICTImageFileType)
+        return PICTtoPNG( rImgData, rPngData);
 
-    bool bResult = false;
+    NSData* pData = [NSData dataWithBytesNoCopy: (void*)rImgData.getConstArray() length: rImgData.getLength() freeWhenDone: 0];
+    if( !pData)
+        return false;
 
-    NSData* pData = [NSData dataWithBytesNoCopy: (void*)aPict.getConstArray() length: aPict.getLength() freeWhenDone: 0];
-    if( pData )
-    {
-        NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData];
-        if( pRep )
-        {
-            NSData* pOut = [pRep representationUsingType: NSBMPFileType properties: nil];
-            if( pOut )
-            {
-                aBmp.realloc( [pOut length] );
-                [pOut getBytes: aBmp.getArray() length: aBmp.getLength()];
-                bResult = (aBmp.getLength() != 0);
-            }
-        }
-    }
+    NSBitmapImageRep* pRep =[NSBitmapImageRep imageRepWithData: pData];
+        if( !pRep)
+        return false;
 
-    return bResult;
+    NSData* pOut = [pRep representationUsingType: NSPNGFileType properties: nil];
+    if( !pOut)
+        return false;
+
+    const size_t nPngSize = [pOut length];
+    rPngData.realloc( nPngSize);
+    [pOut getBytes: rPngData.getArray() length: nPngSize];
+    return (nPngSize > 0);
 }
 
-bool BMPToImage( com::sun::star::uno::Sequence<sal_Int8>& aBmp,
-                 com::sun::star::uno::Sequence<sal_Int8>& aPict,
+bool PNGToImage( com::sun::star::uno::Sequence<sal_Int8>& rPngData,
+                 com::sun::star::uno::Sequence<sal_Int8>& rImgData,
                  NSBitmapImageFileType eOutFormat
                 )
 {
-    if( eOutFormat == PICTImageFileType )
-        return BMPtoPICT( aBmp, aPict );
+    if( eOutFormat == PICTImageFileType)
+        return PNGtoPICT( rPngData, rImgData);
 
-    bool bResult = false;
+    NSData* pData = [NSData dataWithBytesNoCopy: const_cast<sal_Int8*>(rPngData.getConstArray()) length: rPngData.getLength() freeWhenDone: 0];
+    if( !pData)
+        return false;
 
-    NSData* pData = [NSData dataWithBytesNoCopy: const_cast<sal_Int8*>(aBmp.getConstArray()) length: aBmp.getLength() freeWhenDone: 0];
-    if( pData )
-    {
         NSBitmapImageRep* pRep = [NSBitmapImageRep imageRepWithData: pData];
-        if( pRep )
-        {
-            NSData* pOut = [pRep representationUsingType: eOutFormat properties: nil];
-            if( pOut )
-            {
-                aPict.realloc( [pOut length] );
-                [pOut getBytes: aPict.getArray() length: aPict.getLength()];
-                bResult = (aPict.getLength() != 0);
-            }
-        }
-    }
+        if( !pRep)
+        return false;
+

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list