Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / source / gdi / impbmp.cxx
blob4342bc8e64022bef74c93fa5d7ec0f5806beed5e
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
22 #include <svdata.hxx>
23 #include <salinst.hxx>
24 #include <salbmp.hxx>
25 #include <impbmp.hxx>
27 ImpBitmap::ImpBitmap()
28 : mpSalBitmap(ImplGetSVData()->mpDefInst->CreateSalBitmap())
32 ImpBitmap::ImpBitmap(SalBitmap* pBitmap)
33 : mpSalBitmap(pBitmap)
37 ImpBitmap::~ImpBitmap()
41 bool ImpBitmap::ImplIsEqual(const ImpBitmap& rBmp) const
43 return (rBmp.ImplGetSize() == ImplGetSize() &&
44 rBmp.ImplGetBitCount() == ImplGetBitCount() &&
45 rBmp.ImplGetChecksum() == ImplGetChecksum());
48 bool ImpBitmap::ImplCreate(const Size& rSize, sal_uInt16 nBitCount, const BitmapPalette& rPal)
50 return mpSalBitmap->Create( rSize, nBitCount, rPal );
53 bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap )
55 return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap );
58 bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, SalGraphics* pGraphics )
60 return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, pGraphics );
63 bool ImpBitmap::ImplCreate( const ImpBitmap& rImpBitmap, sal_uInt16 nNewBitCount )
65 return mpSalBitmap->Create( *rImpBitmap.mpSalBitmap, nNewBitCount );
68 Size ImpBitmap::ImplGetSize() const
70 return mpSalBitmap->GetSize();
73 sal_uInt16 ImpBitmap::ImplGetBitCount() const
75 sal_uInt16 nBitCount = mpSalBitmap->GetBitCount();
76 return ( nBitCount <= 4 ) ? ( ( nBitCount <= 1 ) ? 1 : 4 ):
77 ( ( nBitCount <= 8 ) ? 8 : 24);
80 BitmapBuffer* ImpBitmap::ImplAcquireBuffer( BitmapAccessMode nMode )
82 return mpSalBitmap->AcquireBuffer( nMode );
85 void ImpBitmap::ImplReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode )
87 mpSalBitmap->ReleaseBuffer( pBuffer, nMode );
89 if( nMode == BitmapAccessMode::Write )
90 ImplInvalidateChecksum();
93 BitmapChecksum ImpBitmap::ImplGetChecksum() const
95 SalBitmap::ChecksumType aChecksum;
96 mpSalBitmap->GetChecksum(aChecksum);
97 return aChecksum;
100 void ImpBitmap::ImplInvalidateChecksum()
102 mpSalBitmap->InvalidateChecksum();
105 bool ImpBitmap::ImplScalingSupported() const
107 return mpSalBitmap->ScalingSupported();
110 bool ImpBitmap::ImplScale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag )
112 return mpSalBitmap->Scale( rScaleX, rScaleY, nScaleFlag );
115 bool ImpBitmap::ImplReplace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol )
117 return mpSalBitmap->Replace( rSearchColor, rReplaceColor, nTol );
120 bool ImpBitmap::ImplConvert( BmpConversion eConversion )
122 // avoid large chunk of obsolete and hopefully rarely used conversions.
123 if (eConversion != BmpConversion::N8BitGreys)
124 return false;
126 // frequently used conversion for creating alpha masks
127 return mpSalBitmap->ConvertToGreyscale();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */