xref: /aoo42x/main/vcl/inc/win/salbmp.h (revision fa064a0d)
12123d757SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32123d757SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42123d757SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52123d757SAndrew Rist  * distributed with this work for additional information
62123d757SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72123d757SAndrew Rist  * to you under the Apache License, Version 2.0 (the
82123d757SAndrew Rist  * "License"); you may not use this file except in compliance
92123d757SAndrew Rist  * with the License.  You may obtain a copy of the License at
102123d757SAndrew Rist  *
112123d757SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122123d757SAndrew Rist  *
132123d757SAndrew Rist  * Unless required by applicable law or agreed to in writing,
142123d757SAndrew Rist  * software distributed under the License is distributed on an
152123d757SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162123d757SAndrew Rist  * KIND, either express or implied.  See the License for the
172123d757SAndrew Rist  * specific language governing permissions and limitations
182123d757SAndrew Rist  * under the License.
192123d757SAndrew Rist  *
202123d757SAndrew Rist  *************************************************************/
212123d757SAndrew Rist 
222123d757SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_SALBMP_H
25cdf0e10cSrcweir #define _SV_SALBMP_H
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <tools/gen.hxx>
28cdf0e10cSrcweir #include <win/wincomp.hxx>
29cdf0e10cSrcweir #include <salbmp.hxx>
305f27b83cSArmin Le Grand #include <boost/shared_ptr.hpp>
31cdf0e10cSrcweir 
32cdf0e10cSrcweir // --------------
33cdf0e10cSrcweir // - SalBitmap	-
34cdf0e10cSrcweir // --------------
35cdf0e10cSrcweir 
36cdf0e10cSrcweir struct	BitmapBuffer;
37cdf0e10cSrcweir class	BitmapColor;
38cdf0e10cSrcweir class	BitmapPalette;
39cdf0e10cSrcweir class	SalGraphics;
405f27b83cSArmin Le Grand namespace Gdiplus { class Bitmap; }
415f27b83cSArmin Le Grand typedef boost::shared_ptr< Gdiplus::Bitmap > GdiPlusBmpPtr;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir class WinSalBitmap : public SalBitmap
44cdf0e10cSrcweir {
45cdf0e10cSrcweir private:
46*fa064a0dSArmin Le Grand     friend class GdiPlusBuffer; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
47cdf0e10cSrcweir 
48cdf0e10cSrcweir 	Size				maSize;
49cdf0e10cSrcweir 	HGLOBAL 			mhDIB;
50cdf0e10cSrcweir 	HBITMAP 			mhDDB;
515f27b83cSArmin Le Grand 
525f27b83cSArmin Le Grand     // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
535f27b83cSArmin Le Grand     // GdiPlusBuffer. To make this safe, it is only handed out as shared
54*fa064a0dSArmin Le Grand     // pointer; the GdiPlusBuffer may delete the local instance.
55*fa064a0dSArmin Le Grand     //
56*fa064a0dSArmin Le Grand     // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
57*fa064a0dSArmin Le Grand     // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
58*fa064a0dSArmin Le Grand     // instance and remembered only on the content-WinSalBitmap, not on the
59*fa064a0dSArmin Le Grand     // alpha-WinSalBitmap.
605f27b83cSArmin Le Grand     GdiPlusBmpPtr       maGdiPlusBitmap;
61*fa064a0dSArmin Le Grand     const WinSalBitmap* mpAssociatedAlpha;
625f27b83cSArmin Le Grand 
635f27b83cSArmin Le Grand     sal_uInt16			mnBitCount;
645f27b83cSArmin Le Grand 
655f27b83cSArmin Le Grand     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
665f27b83cSArmin Le Grand     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap();
67cdf0e10cSrcweir 
68cdf0e10cSrcweir public:
69cdf0e10cSrcweir 
ImplGethDIB() const70cdf0e10cSrcweir 	HGLOBAL 			ImplGethDIB() const { return mhDIB; }
ImplGethDDB() const71cdf0e10cSrcweir 	HBITMAP 			ImplGethDDB() const { return mhDDB; }
725f27b83cSArmin Le Grand 
735f27b83cSArmin Le Grand     GdiPlusBmpPtr ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = 0) const;
74cdf0e10cSrcweir 
75cdf0e10cSrcweir 	static HGLOBAL		ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
76cdf0e10cSrcweir 	static HANDLE		ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
775f27b83cSArmin Le Grand 	static sal_uInt16	ImplGetDIBColorCount( HGLOBAL hDIB );
78cdf0e10cSrcweir 	static void 		ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf,
79cdf0e10cSrcweir 											 const Size& rSizePixel, bool bRLE4 );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir public:
82cdf0e10cSrcweir 
83cdf0e10cSrcweir 						WinSalBitmap();
84cdf0e10cSrcweir 	virtual				~WinSalBitmap();
85cdf0e10cSrcweir 
86cdf0e10cSrcweir public:
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 	bool                        Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle );
89cdf0e10cSrcweir 	virtual bool                Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
90cdf0e10cSrcweir 	virtual bool                Create( const SalBitmap& rSalBmpImpl );
91cdf0e10cSrcweir 	virtual bool                Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics );
92cdf0e10cSrcweir 	virtual bool                Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount );
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	virtual void                Destroy();
95cdf0e10cSrcweir 
GetSize() const96cdf0e10cSrcweir 	virtual Size                GetSize() const { return maSize; }
GetBitCount() const97cdf0e10cSrcweir 	virtual sal_uInt16              GetBitCount() const { return mnBitCount; }
98cdf0e10cSrcweir 
99cdf0e10cSrcweir 	virtual BitmapBuffer*		AcquireBuffer( bool bReadOnly );
100cdf0e10cSrcweir 	virtual void                ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
101cdf0e10cSrcweir     virtual bool                GetSystemData( BitmapSystemData& rData );
102cdf0e10cSrcweir };
103cdf0e10cSrcweir 
104cdf0e10cSrcweir #endif // _SV_SALBMP_HXX
105