xref: /aoo42x/main/vcl/inc/win/salbmp.h (revision fa064a0d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_SALBMP_H
25 #define _SV_SALBMP_H
26 
27 #include <tools/gen.hxx>
28 #include <win/wincomp.hxx>
29 #include <salbmp.hxx>
30 #include <boost/shared_ptr.hpp>
31 
32 // --------------
33 // - SalBitmap	-
34 // --------------
35 
36 struct	BitmapBuffer;
37 class	BitmapColor;
38 class	BitmapPalette;
39 class	SalGraphics;
40 namespace Gdiplus { class Bitmap; }
41 typedef boost::shared_ptr< Gdiplus::Bitmap > GdiPlusBmpPtr;
42 
43 class WinSalBitmap : public SalBitmap
44 {
45 private:
46     friend class GdiPlusBuffer; // allow buffer to remove maGdiPlusBitmap and mpAssociatedAlpha eventually
47 
48 	Size				maSize;
49 	HGLOBAL 			mhDIB;
50 	HBITMAP 			mhDDB;
51 
52     // the buffered evtl. used Gdiplus::Bitmap instance. It is managed by
53     // GdiPlusBuffer. To make this safe, it is only handed out as shared
54     // pointer; the GdiPlusBuffer may delete the local instance.
55     //
56     // mpAssociatedAlpha holds the last WinSalBitmap used to construct an
57     // evtl. buffered GdiPlusBmp. This is needed since the GdiPlusBmp is a single
58     // instance and remembered only on the content-WinSalBitmap, not on the
59     // alpha-WinSalBitmap.
60     GdiPlusBmpPtr       maGdiPlusBitmap;
61     const WinSalBitmap* mpAssociatedAlpha;
62 
63     sal_uInt16			mnBitCount;
64 
65     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
66     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap();
67 
68 public:
69 
ImplGethDIB() const70 	HGLOBAL 			ImplGethDIB() const { return mhDIB; }
ImplGethDDB() const71 	HBITMAP 			ImplGethDDB() const { return mhDDB; }
72 
73     GdiPlusBmpPtr ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = 0) const;
74 
75 	static HGLOBAL		ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
76 	static HANDLE		ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
77 	static sal_uInt16	ImplGetDIBColorCount( HGLOBAL hDIB );
78 	static void 		ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf,
79 											 const Size& rSizePixel, bool bRLE4 );
80 
81 public:
82 
83 						WinSalBitmap();
84 	virtual				~WinSalBitmap();
85 
86 public:
87 
88 	bool                        Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle );
89 	virtual bool                Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
90 	virtual bool                Create( const SalBitmap& rSalBmpImpl );
91 	virtual bool                Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics );
92 	virtual bool                Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount );
93 
94 	virtual void                Destroy();
95 
GetSize() const96 	virtual Size                GetSize() const { return maSize; }
GetBitCount() const97 	virtual sal_uInt16              GetBitCount() const { return mnBitCount; }
98 
99 	virtual BitmapBuffer*		AcquireBuffer( bool bReadOnly );
100 	virtual void                ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
101     virtual bool                GetSystemData( BitmapSystemData& rData );
102 };
103 
104 #endif // _SV_SALBMP_HXX
105