Implement weld::IconView::[gs]et_item_width
[LibreOffice.git] / vcl / inc / salbmp.hxx
blobf04ea291aa84c3d2647ac44f0a00f4483cfc047d
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 <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>
31 struct BitmapBuffer;
32 class Color;
33 class SalGraphics;
34 class BitmapPalette;
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
46 public:
48 SalBitmap()
49 : mnChecksum(0)
50 , mbChecksumValid(false)
54 virtual ~SalBitmap();
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,
65 Size& rSize,
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()
83 return false;
85 virtual bool InterpretAs8Bit()
87 return false;
90 virtual bool Erase( const Color& /*color*/ )
92 return false;
94 // Optimized case for AlphaMask::BlendWith().
95 virtual bool AlphaBlendWith( const SalBitmap& /*rSalBmp*/ )
97 return false;
100 BitmapChecksum GetChecksum() const
102 updateChecksum();
103 if (!mbChecksumValid)
104 return 0; // back-compat
105 return mnChecksum;
108 void InvalidateChecksum()
110 mbChecksumValid = false;
113 protected:
114 BitmapChecksum mnChecksum;
115 bool mbChecksumValid;
117 protected:
118 void updateChecksum() const;
119 // helper function to convert data in 1,2,4 bpp formats to a 8/24/32bpp format
120 enum class BitConvert
123 RGBA,
124 BGRA,
125 LAST = BGRA
127 static std::unique_ptr< sal_uInt8[] > convertDataBitCount( const sal_uInt8* src,
128 int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette,
129 BitConvert type );
132 #endif
134 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */