Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <vcl/bitmap.hxx>
31 : :
32 : : #include <svdata.hxx>
33 : : #include <salinst.hxx>
34 : : #include <salbmp.hxx>
35 : : #include <impbmp.hxx>
36 : :
37 : : // --------------
38 : : // - ImpBitmap -
39 : : // --------------
40 : :
41 : 671556 : ImpBitmap::ImpBitmap() :
42 : : mnRefCount ( 1UL ),
43 : : mnChecksum ( 0UL ),
44 : 671556 : mpSalBitmap ( ImplGetSVData()->mpDefInst->CreateSalBitmap() ),
45 : 671556 : maSourceSize( 0, 0 )
46 : : {
47 : 671556 : }
48 : :
49 : : // -----------------------------------------------------------------------
50 : :
51 : 671522 : ImpBitmap::~ImpBitmap()
52 : : {
53 [ + - ]: 671522 : delete mpSalBitmap;
54 : 671522 : }
55 : :
56 : : // -----------------------------------------------------------------------
57 : 212773 : void ImpBitmap::ImplSetSalBitmap( SalBitmap* pBitmap )
58 : : {
59 [ + - ]: 212773 : delete mpSalBitmap, mpSalBitmap = pBitmap;
60 : 212773 : }
61 : :
62 : : // -----------------------------------------------------------------------
63 : :
64 : 250924 : sal_Bool ImpBitmap::ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
65 : : {
66 : 250924 : maSourceSize = rSize;
67 : 250924 : return mpSalBitmap->Create( rSize, nBitCount, rPal );
68 : : }
69 : :
70 : : // -----------------------------------------------------------------------
71 : :
72 : 207847 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap )
73 : : {
74 : 207847 : maSourceSize = rImpBitmap.maSourceSize;
75 : 207847 : mnChecksum = rImpBitmap.mnChecksum;
76 : 207847 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap );
77 : : }
78 : :
79 : : // -----------------------------------------------------------------------
80 : :
81 : 6 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, SalGraphics* pGraphics )
82 : : {
83 : 6 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, pGraphics );
84 : : }
85 : :
86 : : // -----------------------------------------------------------------------
87 : :
88 : 6 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, sal_uInt16 nNewBitCount )
89 : : {
90 : 6 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, nNewBitCount );
91 : : }
92 : :
93 : : // -----------------------------------------------------------------------
94 : :
95 : 1678756 : Size ImpBitmap::ImplGetSize() const
96 : : {
97 : 1678756 : return mpSalBitmap->GetSize();
98 : : }
99 : :
100 : : // -----------------------------------------------------------------------
101 : :
102 : 472379 : sal_uInt16 ImpBitmap::ImplGetBitCount() const
103 : : {
104 : 472379 : sal_uInt16 nBitCount = mpSalBitmap->GetBitCount();
105 [ + + ][ + + ]: 472379 : return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : 24 );
[ + + ]
106 : : }
107 : :
108 : : // -----------------------------------------------------------------------
109 : :
110 : 1279948 : BitmapBuffer* ImpBitmap::ImplAcquireBuffer( sal_Bool bReadOnly )
111 : : {
112 : 1279948 : return mpSalBitmap->AcquireBuffer( bReadOnly );
113 : : }
114 : :
115 : : // -----------------------------------------------------------------------
116 : :
117 : 1279942 : void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, sal_Bool bReadOnly )
118 : : {
119 : 1279942 : mpSalBitmap->ReleaseBuffer( pBuffer, bReadOnly );
120 : :
121 [ + + ]: 1279942 : if( !bReadOnly )
122 : 458437 : mnChecksum = 0;
123 : 1279942 : }
124 : :
125 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|