build fix
[LibreOffice.git] / vcl / inc / salbmp.hxx
blob47d0c0280400557570b91f20a8abe2f955f3d048
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 #ifndef INCLUDED_VCL_INC_SALBMP_HXX
21 #define INCLUDED_VCL_INC_SALBMP_HXX
23 #include <tools/gen.hxx>
24 #include <vcl/checksum.hxx>
25 #include <vcl/salbtype.hxx>
27 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
29 struct BitmapBuffer;
30 class Color;
31 class SalGraphics;
32 class BitmapPalette;
33 struct BitmapSystemData;
34 enum class BmpScaleFlag;
36 class VCL_PLUGIN_PUBLIC SalBitmap
38 public:
40 typedef BitmapChecksum ChecksumType;
42 SalBitmap()
43 : mnChecksum(0)
44 , mbChecksumValid(false)
48 virtual ~SalBitmap();
50 virtual bool Create( const Size& rSize,
51 sal_uInt16 nBitCount,
52 const BitmapPalette& rPal ) = 0;
53 virtual bool Create( const SalBitmap& rSalBmp ) = 0;
54 virtual bool Create( const SalBitmap& rSalBmp,
55 SalGraphics* pGraphics ) = 0;
56 virtual bool Create( const SalBitmap& rSalBmp,
57 sal_uInt16 nNewBitCount ) = 0;
58 virtual bool Create( const css::uno::Reference< css::rendering::XBitmapCanvas >& rBitmapCanvas,
59 Size& rSize,
60 bool bMask = false ) = 0;
61 virtual void Destroy() = 0;
62 virtual Size GetSize() const = 0;
63 virtual sal_uInt16 GetBitCount() const = 0;
65 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
66 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
67 virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
69 virtual bool ScalingSupported() const = 0;
70 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
71 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0;
73 virtual bool ConvertToGreyscale()
75 return false;
78 void GetChecksum(ChecksumType& rChecksum) const
80 updateChecksum();
81 if (!mbChecksumValid)
82 rChecksum = 0; // back-compat
83 else
84 rChecksum = mnChecksum;
87 void InvalidateChecksum()
89 mbChecksumValid = false;
92 protected:
93 ChecksumType mnChecksum;
94 bool mbChecksumValid;
96 protected:
97 virtual void updateChecksum() const
99 if (mbChecksumValid)
100 return;
102 ChecksumType nCrc = 0;
103 SalBitmap* pThis = const_cast<SalBitmap*>(this);
104 BitmapBuffer* pBuf = pThis->AcquireBuffer(BitmapAccessMode::Read);
105 if (pBuf)
107 nCrc = pBuf->maPalette.GetChecksum();
108 nCrc = vcl_get_checksum(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
109 pThis->ReleaseBuffer(pBuf, BitmapAccessMode::Read);
110 pThis->mnChecksum = nCrc;
111 pThis->mbChecksumValid = true;
113 else
115 pThis->mbChecksumValid = false;
122 #endif
124 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */