1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
23 #include <tools/gen.hxx>
24 #include <win/wincomp.hxx>
26 #include <boost/shared_ptr.hpp>
36 namespace Gdiplus
{ class Bitmap
; }
37 typedef boost::shared_ptr
< Gdiplus::Bitmap
> GdiPlusBmpPtr
;
39 class WinSalBitmap
: public SalBitmap
42 friend class GdiPlusBuffer
; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
48 // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
49 // GdiPlusBuffer. To make this safe, it is only handed out as shared
50 // pointer; the GdiPlusBuffer may delete the local instance.
52 // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
53 // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
54 // instance and remembered only on the content-WinSalBitmap, not on the
55 // alpha-WinSalBitmap.
56 GdiPlusBmpPtr maGdiPlusBitmap
;
57 const WinSalBitmap
* mpAssociatedAlpha
;
59 sal_uInt16 mnBitCount
;
61 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap(const WinSalBitmap
& rAlphaSource
);
62 Gdiplus::Bitmap
* ImplCreateGdiPlusBitmap();
66 HGLOBAL
ImplGethDIB() const { return mhDIB
; }
67 HBITMAP
ImplGethDDB() const { return mhDDB
; }
69 GdiPlusBmpPtr
ImplGetGdiPlusBitmap(const WinSalBitmap
* pAlphaSource
= 0) const;
71 static HGLOBAL
ImplCreateDIB( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
);
72 static HANDLE
ImplCopyDIBOrDDB( HANDLE hHdl
, bool bDIB
);
73 static sal_uInt16
ImplGetDIBColorCount( HGLOBAL hDIB
);
74 static void ImplDecodeRLEBuffer( const BYTE
* pSrcBuf
, BYTE
* pDstBuf
,
75 const Size
& rSizePixel
, bool bRLE4
);
80 virtual ~WinSalBitmap();
84 bool Create( HANDLE hBitmap
, bool bDIB
, bool bCopyHandle
);
85 virtual bool Create( const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
);
86 virtual bool Create( const SalBitmap
& rSalBmpImpl
);
87 virtual bool Create( const SalBitmap
& rSalBmpImpl
, SalGraphics
* pGraphics
);
88 virtual bool Create( const SalBitmap
& rSalBmpImpl
, sal_uInt16 nNewBitCount
);
89 virtual bool Create( const ::com::sun::star::uno::Reference
< ::com::sun::star::rendering::XBitmapCanvas
> xBitmapCanvas
,
93 virtual void Destroy();
95 virtual Size
GetSize() const { return maSize
; }
96 virtual sal_uInt16
GetBitCount() const { return mnBitCount
; }
98 virtual BitmapBuffer
* AcquireBuffer( bool bReadOnly
);
99 virtual void ReleaseBuffer( BitmapBuffer
* pBuffer
, bool bReadOnly
);
100 virtual bool GetSystemData( BitmapSystemData
& rData
);
103 #endif // _SV_SALBMP_HXX
105 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */