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 <vcl/bitmap/BitmapTypes.hxx>
29 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
35 struct BitmapSystemData
;
36 enum class BmpScaleFlag
;
38 extern const sal_uLong nVCLRLut
[ 6 ];
39 extern const sal_uLong nVCLGLut
[ 6 ];
40 extern const sal_uLong nVCLBLut
[ 6 ];
41 extern const sal_uLong nVCLDitherLut
[ 256 ];
42 extern const sal_uLong nVCLLut
[ 256 ];
44 class VCL_PLUGIN_PUBLIC SalBitmap
50 , mbChecksumValid(false)
56 virtual bool Create( const Size
& rSize
,
57 vcl::PixelFormat ePixelFormat
,
58 const BitmapPalette
& rPal
) = 0;
59 virtual bool Create( const SalBitmap
& rSalBmp
) = 0;
60 virtual bool Create( const SalBitmap
& rSalBmp
,
61 SalGraphics
* pGraphics
) = 0;
62 virtual bool Create( const SalBitmap
& rSalBmp
,
63 vcl::PixelFormat eNewPixelFormat
) = 0;
64 virtual bool Create( const css::uno::Reference
< css::rendering::XBitmapCanvas
>& rBitmapCanvas
,
66 bool bMask
= false ) = 0;
67 virtual void Destroy() = 0;
68 virtual Size
GetSize() const = 0;
69 virtual sal_uInt16
GetBitCount() const = 0;
71 virtual BitmapBuffer
* AcquireBuffer( BitmapAccessMode nMode
) = 0;
72 virtual void ReleaseBuffer( BitmapBuffer
* pBuffer
, BitmapAccessMode nMode
) = 0;
73 virtual bool GetSystemData( BitmapSystemData
& rData
) = 0;
75 virtual bool ScalingSupported() const = 0;
76 virtual bool Scale( const double& rScaleX
, const double& rScaleY
, BmpScaleFlag nScaleFlag
) = 0;
77 void DropScaledCache();
79 virtual bool Replace( const Color
& rSearchColor
, const Color
& rReplaceColor
, sal_uInt8 nTol
) = 0;
81 virtual bool ConvertToGreyscale()
85 virtual bool InterpretAs8Bit()
90 virtual bool Erase( const Color
& /*color*/ )
94 // Optimized case for AlphaMask::BlendWith().
95 virtual bool AlphaBlendWith( const SalBitmap
& /*rSalBmp*/ )
100 void GetChecksum(BitmapChecksum
& rChecksum
) const
103 if (!mbChecksumValid
)
104 rChecksum
= 0; // back-compat
106 rChecksum
= mnChecksum
;
109 void InvalidateChecksum()
111 mbChecksumValid
= false;
115 BitmapChecksum mnChecksum
;
116 bool mbChecksumValid
;
119 void updateChecksum() const;
120 // helper function to convert data in 1,2,4 bpp formats to a 8/24/32bpp format
121 enum class BitConvert
128 static std::unique_ptr
< sal_uInt8
[] > convertDataBitCount( const sal_uInt8
* src
,
129 int width
, int height
, int bitCount
, int bytesPerRow
, const BitmapPalette
& palette
,
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */