xref: /aoo42x/main/vcl/source/gdi/impbmp.cxx (revision 9f62ea84)
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 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_vcl.hxx"
26 
27 #include <tools/debug.hxx>
28 
29 #include <vcl/bitmap.hxx>
30 
31 #include <svdata.hxx>
32 #include <salinst.hxx>
33 #include <salbmp.hxx>
34 #include <impbmp.hxx>
35 
36 // --------------
37 // - ImpBitmap	-
38 // --------------
39 
ImpBitmap()40 ImpBitmap::ImpBitmap() :
41 			mnRefCount	( 1UL ),
42 			mnChecksum	( 0UL ),
43 			mpSalBitmap ( ImplGetSVData()->mpDefInst->CreateSalBitmap() ),
44 			maSourceSize( 0, 0 )
45 {
46 }
47 
48 // -----------------------------------------------------------------------
49 
~ImpBitmap()50 ImpBitmap::~ImpBitmap()
51 {
52 	delete mpSalBitmap;
53 }
54 
55 // -----------------------------------------------------------------------
ImplSetSalBitmap(SalBitmap * pBitmap)56 void ImpBitmap::ImplSetSalBitmap( SalBitmap* pBitmap )
57 {
58 	delete mpSalBitmap, mpSalBitmap = pBitmap;
59 }
60 
61 // -----------------------------------------------------------------------
62 
ImplCreate(const Size & rSize,sal_uInt16 nBitCount,const BitmapPalette & rPal)63 sal_Bool ImpBitmap::ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
64 {
65 	maSourceSize = rSize;
66 	return mpSalBitmap->Create( rSize, nBitCount, rPal );
67 }
68 
69 // -----------------------------------------------------------------------
70 
ImplCreate(const ImpBitmap & rImpBitmap)71 sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap )
72 {
73 	maSourceSize = rImpBitmap.maSourceSize;
74 	mnChecksum = rImpBitmap.mnChecksum;
75 	return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap );
76 }
77 
78 // -----------------------------------------------------------------------
79 
ImplCreate(const ImpBitmap & rImpBitmap,SalGraphics * pGraphics)80 sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, SalGraphics* pGraphics )
81 {
82 	return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, pGraphics );
83 }
84 
85 // -----------------------------------------------------------------------
86 
ImplCreate(const ImpBitmap & rImpBitmap,sal_uInt16 nNewBitCount)87 sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, sal_uInt16 nNewBitCount )
88 {
89 	return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, nNewBitCount );
90 }
91 
92 // -----------------------------------------------------------------------
93 
ImplDestroy()94 void ImpBitmap::ImplDestroy()
95 {
96 	mpSalBitmap->Destroy();
97 }
98 
99 // -----------------------------------------------------------------------
100 
ImplGetSize() const101 Size ImpBitmap::ImplGetSize() const
102 {
103 	return mpSalBitmap->GetSize();
104 }
105 
106 // -----------------------------------------------------------------------
107 
ImplGetBitCount() const108 sal_uInt16 ImpBitmap::ImplGetBitCount() const
109 {
110 	sal_uInt16 nBitCount = mpSalBitmap->GetBitCount();
111 	return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : 24 );
112 }
113 
114 // -----------------------------------------------------------------------
115 
ImplAcquireBuffer(sal_Bool bReadOnly)116 BitmapBuffer* ImpBitmap::ImplAcquireBuffer( sal_Bool bReadOnly )
117 {
118 	return mpSalBitmap->AcquireBuffer( bReadOnly );
119 }
120 
121 // -----------------------------------------------------------------------
122 
ImplReleaseBuffer(BitmapBuffer * pBuffer,sal_Bool bReadOnly)123 void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, sal_Bool bReadOnly )
124 {
125 	mpSalBitmap->ReleaseBuffer( pBuffer, bReadOnly );
126 
127 	if( !bReadOnly )
128 		mnChecksum = 0;
129 }
130