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 #ifndef INCLUDED_VCL_INC_SALBMP_HXX
21 #define INCLUDED_VCL_INC_SALBMP_HXX
23 #include <tools/gen.hxx>
24 #include <tools/solar.h>
25 #include <vcl/checksum.hxx>
26 #include <vcl/BitmapAccessMode.hxx>
27 #include <vcl/BitmapBuffer.hxx>
28 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
34 struct BitmapSystemData
;
35 enum class BmpScaleFlag
;
37 extern const sal_uLong nVCLRLut
[ 6 ];
38 extern const sal_uLong nVCLGLut
[ 6 ];
39 extern const sal_uLong nVCLBLut
[ 6 ];
40 extern const sal_uLong nVCLDitherLut
[ 256 ];
41 extern const sal_uLong nVCLLut
[ 256 ];
43 class VCL_PLUGIN_PUBLIC SalBitmap
49 , mbChecksumValid(false)
55 virtual bool Create( const Size
& rSize
,
57 const BitmapPalette
& rPal
) = 0;
58 virtual bool Create( const SalBitmap
& rSalBmp
) = 0;
59 virtual bool Create( const SalBitmap
& rSalBmp
,
60 SalGraphics
* pGraphics
) = 0;
61 virtual bool Create( const SalBitmap
& rSalBmp
,
62 sal_uInt16 nNewBitCount
) = 0;
63 virtual bool Create( const css::uno::Reference
< css::rendering::XBitmapCanvas
>& rBitmapCanvas
,
65 bool bMask
= false ) = 0;
66 virtual void Destroy() = 0;
67 virtual Size
GetSize() const = 0;
68 virtual sal_uInt16
GetBitCount() const = 0;
70 virtual BitmapBuffer
* AcquireBuffer( BitmapAccessMode nMode
) = 0;
71 virtual void ReleaseBuffer( BitmapBuffer
* pBuffer
, BitmapAccessMode nMode
) = 0;
72 virtual bool GetSystemData( BitmapSystemData
& rData
) = 0;
74 virtual bool ScalingSupported() const = 0;
75 virtual bool Scale( const double& rScaleX
, const double& rScaleY
, BmpScaleFlag nScaleFlag
) = 0;
76 void DropScaledCache();
78 virtual bool Replace( const Color
& rSearchColor
, const Color
& rReplaceColor
, sal_uInt8 nTol
) = 0;
80 virtual bool ConvertToGreyscale()
85 void GetChecksum(BitmapChecksum
& rChecksum
) const
89 rChecksum
= 0; // back-compat
91 rChecksum
= mnChecksum
;
94 void InvalidateChecksum()
96 mbChecksumValid
= false;
100 BitmapChecksum mnChecksum
;
101 bool mbChecksumValid
;
104 virtual void updateChecksum() const
109 BitmapChecksum nCrc
= 0;
110 SalBitmap
* pThis
= const_cast<SalBitmap
*>(this);
111 BitmapBuffer
* pBuf
= pThis
->AcquireBuffer(BitmapAccessMode::Read
);
114 nCrc
= pBuf
->maPalette
.GetChecksum();
115 nCrc
= vcl_get_checksum(nCrc
, pBuf
->mpBits
, pBuf
->mnScanlineSize
* pBuf
->mnHeight
);
116 pThis
->ReleaseBuffer(pBuf
, BitmapAccessMode::Read
);
117 pThis
->mnChecksum
= nCrc
;
118 pThis
->mbChecksumValid
= true;
122 pThis
->mbChecksumValid
= false;
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */