1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <vcl/bitmap.hxx>
23 #include <salinst.hxx>
27 ImpBitmap::ImpBitmap() :
29 mpSalBitmap ( ImplGetSVData()->mpDefInst
->CreateSalBitmap() )
33 ImpBitmap::ImpBitmap(SalBitmap
* pBitmap
) :
35 mpSalBitmap ( pBitmap
)
39 ImpBitmap::~ImpBitmap()
44 bool ImpBitmap::ImplIsEqual(const ImpBitmap
& rBmp
) const
46 return (rBmp
.ImplGetSize() == ImplGetSize() &&
47 rBmp
.ImplGetBitCount() == ImplGetBitCount() &&
48 rBmp
.ImplGetChecksum() == ImplGetChecksum());
51 bool ImpBitmap::ImplCreate(const Size
& rSize
, sal_uInt16 nBitCount
, const BitmapPalette
& rPal
)
53 return mpSalBitmap
->Create( rSize
, nBitCount
, rPal
);
56 bool ImpBitmap::ImplCreate( const ImpBitmap
& rImpBitmap
)
58 return mpSalBitmap
->Create( *rImpBitmap
.mpSalBitmap
);
61 bool ImpBitmap::ImplCreate( const ImpBitmap
& rImpBitmap
, SalGraphics
* pGraphics
)
63 return mpSalBitmap
->Create( *rImpBitmap
.mpSalBitmap
, pGraphics
);
66 bool ImpBitmap::ImplCreate( const ImpBitmap
& rImpBitmap
, sal_uInt16 nNewBitCount
)
68 return mpSalBitmap
->Create( *rImpBitmap
.mpSalBitmap
, nNewBitCount
);
71 Size
ImpBitmap::ImplGetSize() const
73 return mpSalBitmap
->GetSize();
76 sal_uInt16
ImpBitmap::ImplGetBitCount() const
78 sal_uInt16 nBitCount
= mpSalBitmap
->GetBitCount();
79 return( ( nBitCount
<= 1 ) ? 1 : ( nBitCount
<= 4 ) ? 4 : ( nBitCount
<= 8 ) ? 8 : 24 );
82 BitmapBuffer
* ImpBitmap::ImplAcquireBuffer( BitmapAccessMode nMode
)
84 return mpSalBitmap
->AcquireBuffer( nMode
);
87 void ImpBitmap::ImplReleaseBuffer( BitmapBuffer
* pBuffer
, BitmapAccessMode nMode
)
89 mpSalBitmap
->ReleaseBuffer( pBuffer
, nMode
);
91 if( nMode
== BITMAP_WRITE_ACCESS
)
92 ImplInvalidateChecksum();
95 BitmapChecksum
ImpBitmap::ImplGetChecksum() const
97 SalBitmap::ChecksumType aChecksum
;
98 mpSalBitmap
->GetChecksum(aChecksum
);
102 void ImpBitmap::ImplInvalidateChecksum()
104 mpSalBitmap
->InvalidateChecksum();
107 bool ImpBitmap::ImplScale( const double& rScaleX
, const double& rScaleY
, BmpScaleFlag nScaleFlag
)
109 return mpSalBitmap
->Scale( rScaleX
, rScaleY
, nScaleFlag
);
112 bool ImpBitmap::ImplReplace( const Color
& rSearchColor
, const Color
& rReplaceColor
, sal_uLong nTol
)
114 return mpSalBitmap
->Replace( rSearchColor
, rReplaceColor
, nTol
);
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */