xref: /AOO41X/main/vcl/inc/win/salbmp.h (revision 5443dcac4da55ae8863c5c80e8907938642a7f1b)
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 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     GdiPlusBmpPtr       maGdiPlusBitmap;
56 
57     sal_uInt16          mnBitCount;
58 
59     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap(const WinSalBitmap& rAlphaSource);
60     Gdiplus::Bitmap* ImplCreateGdiPlusBitmap();
61 
62 public:
63 
64     HGLOBAL             ImplGethDIB() const { return mhDIB; }
65     HBITMAP             ImplGethDDB() const { return mhDDB; }
66 
67     GdiPlusBmpPtr ImplGetGdiPlusBitmap(const WinSalBitmap* pAlphaSource = 0) const;
68 
69     static HGLOBAL      ImplCreateDIB( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
70     static HANDLE       ImplCopyDIBOrDDB( HANDLE hHdl, bool bDIB );
71     static sal_uInt16   ImplGetDIBColorCount( HGLOBAL hDIB );
72     static void         ImplDecodeRLEBuffer( const BYTE* pSrcBuf, BYTE* pDstBuf,
73                                              const Size& rSizePixel, bool bRLE4 );
74 
75 public:
76 
77                         WinSalBitmap();
78     virtual             ~WinSalBitmap();
79 
80 public:
81 
82     bool                        Create( HANDLE hBitmap, bool bDIB, bool bCopyHandle );
83     virtual bool                Create( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal );
84     virtual bool                Create( const SalBitmap& rSalBmpImpl );
85     virtual bool                Create( const SalBitmap& rSalBmpImpl, SalGraphics* pGraphics );
86     virtual bool                Create( const SalBitmap& rSalBmpImpl, sal_uInt16 nNewBitCount );
87 
88     virtual void                Destroy();
89 
90     virtual Size                GetSize() const { return maSize; }
91     virtual sal_uInt16              GetBitCount() const { return mnBitCount; }
92 
93     virtual BitmapBuffer*       AcquireBuffer( bool bReadOnly );
94     virtual void                ReleaseBuffer( BitmapBuffer* pBuffer, bool bReadOnly );
95     virtual bool                GetSystemData( BitmapSystemData& rData );
96 };
97 
98 #endif // _SV_SALBMP_HXX
99