Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <vcl/bitmap.hxx>
22 :
23 : #include <svdata.hxx>
24 : #include <salinst.hxx>
25 : #include <salbmp.hxx>
26 : #include <impbmp.hxx>
27 :
28 : // --------------
29 : // - ImpBitmap -
30 : // --------------
31 :
32 274 : ImpBitmap::ImpBitmap() :
33 : mnRefCount ( 1UL ),
34 : mnChecksum ( 0UL ),
35 274 : mpSalBitmap ( ImplGetSVData()->mpDefInst->CreateSalBitmap() ),
36 548 : maSourceSize( 0, 0 )
37 : {
38 274 : }
39 :
40 : // -----------------------------------------------------------------------
41 :
42 249 : ImpBitmap::~ImpBitmap()
43 : {
44 249 : delete mpSalBitmap;
45 249 : }
46 :
47 : // -----------------------------------------------------------------------
48 69 : void ImpBitmap::ImplSetSalBitmap( SalBitmap* pBitmap )
49 : {
50 69 : delete mpSalBitmap, mpSalBitmap = pBitmap;
51 69 : }
52 :
53 : // -----------------------------------------------------------------------
54 :
55 193 : sal_Bool ImpBitmap::ImplCreate( const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal )
56 : {
57 193 : maSourceSize = rSize;
58 193 : return mpSalBitmap->Create( rSize, nBitCount, rPal );
59 : }
60 :
61 : // -----------------------------------------------------------------------
62 :
63 3 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap )
64 : {
65 3 : maSourceSize = rImpBitmap.maSourceSize;
66 3 : mnChecksum = rImpBitmap.mnChecksum;
67 3 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap );
68 : }
69 :
70 : // -----------------------------------------------------------------------
71 :
72 6 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, SalGraphics* pGraphics )
73 : {
74 6 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, pGraphics );
75 : }
76 :
77 : // -----------------------------------------------------------------------
78 :
79 3 : sal_Bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, sal_uInt16 nNewBitCount )
80 : {
81 3 : return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, nNewBitCount );
82 : }
83 :
84 : // -----------------------------------------------------------------------
85 :
86 423 : Size ImpBitmap::ImplGetSize() const
87 : {
88 423 : return mpSalBitmap->GetSize();
89 : }
90 :
91 : // -----------------------------------------------------------------------
92 :
93 311 : sal_uInt16 ImpBitmap::ImplGetBitCount() const
94 : {
95 311 : sal_uInt16 nBitCount = mpSalBitmap->GetBitCount();
96 311 : return( ( nBitCount <= 1 ) ? 1 : ( nBitCount <= 4 ) ? 4 : ( nBitCount <= 8 ) ? 8 : 24 );
97 : }
98 :
99 : // -----------------------------------------------------------------------
100 :
101 392 : BitmapBuffer* ImpBitmap::ImplAcquireBuffer( sal_Bool bReadOnly )
102 : {
103 392 : return mpSalBitmap->AcquireBuffer( bReadOnly );
104 : }
105 :
106 : // -----------------------------------------------------------------------
107 :
108 389 : void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, sal_Bool bReadOnly )
109 : {
110 389 : mpSalBitmap->ReleaseBuffer( pBuffer, bReadOnly );
111 :
112 389 : if( !bReadOnly )
113 260 : mnChecksum = 0;
114 389 : }
115 :
116 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|