LibreOffice Module vcl (master) 1
salbmp.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#ifndef INCLUDED_VCL_INC_SALBMP_HXX
21#define INCLUDED_VCL_INC_SALBMP_HXX
22
23#include <tools/gen.hxx>
24#include <tools/solar.h>
25#include <vcl/checksum.hxx>
27#include <vcl/BitmapBuffer.hxx>
29#include <com/sun/star/rendering/XBitmapCanvas.hpp>
30
31struct BitmapBuffer;
32class Color;
33class SalGraphics;
34class BitmapPalette;
35struct BitmapSystemData;
36enum class BmpScaleFlag;
37
38extern const sal_uLong nVCLRLut[ 6 ];
39extern const sal_uLong nVCLGLut[ 6 ];
40extern const sal_uLong nVCLBLut[ 6 ];
41extern const sal_uLong nVCLDitherLut[ 256 ];
42extern const sal_uLong nVCLLut[ 256 ];
43
45{
46public:
47
49 : mnChecksum(0)
50 , mbChecksumValid(false)
51 {
52 }
53
54 virtual ~SalBitmap();
55
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;
70
72 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
73 virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
74
75 virtual bool ScalingSupported() const = 0;
76 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
77 void DropScaledCache();
78
79 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) = 0;
80
81 virtual bool ConvertToGreyscale()
82 {
83 return false;
84 }
85 virtual bool InterpretAs8Bit()
86 {
87 return false;
88 }
89
90 virtual bool Erase( const Color& /*color*/ )
91 {
92 return false;
93 }
94 // Optimized case for AlphaMask::BlendWith().
95 virtual bool AlphaBlendWith( const SalBitmap& /*rSalBmp*/ )
96 {
97 return false;
98 }
99
101 {
102 updateChecksum();
103 if (!mbChecksumValid)
104 return 0; // back-compat
105 return mnChecksum;
106 }
107
109 {
110 mbChecksumValid = false;
111 }
112
113protected:
116
117protected:
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
121 {
122 A8,
123 RGBA,
124 BGRA,
125 LAST = BGRA
126 };
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 );
130};
131
132#endif
133
134/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
BitmapAccessMode
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
virtual bool Erase(const Color &)
Definition: salbmp.hxx:90
BitmapChecksum mnChecksum
Definition: salbmp.hxx:114
SalBitmap()
Definition: salbmp.hxx:48
virtual bool Scale(const double &rScaleX, const double &rScaleY, BmpScaleFlag nScaleFlag)=0
virtual void Destroy()=0
bool mbChecksumValid
Definition: salbmp.hxx:115
virtual sal_uInt16 GetBitCount() const =0
virtual bool ConvertToGreyscale()
Definition: salbmp.hxx:81
virtual bool InterpretAs8Bit()
Definition: salbmp.hxx:85
virtual bool Replace(const Color &rSearchColor, const Color &rReplaceColor, sal_uInt8 nTol)=0
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode)=0
virtual bool AlphaBlendWith(const SalBitmap &)
Definition: salbmp.hxx:95
virtual bool GetSystemData(BitmapSystemData &rData)=0
virtual Size GetSize() const =0
virtual bool Create(const SalBitmap &rSalBmp)=0
void InvalidateChecksum()
Definition: salbmp.hxx:108
virtual BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode)=0
BitmapChecksum GetChecksum() const
Definition: salbmp.hxx:100
virtual bool ScalingSupported() const =0
virtual bool Create(const css::uno::Reference< css::rendering::XBitmapCanvas > &rBitmapCanvas, Size &rSize, bool bMask=false)=0
virtual bool Create(const Size &rSize, vcl::PixelFormat ePixelFormat, const BitmapPalette &rPal)=0
virtual bool Create(const SalBitmap &rSalBmp, SalGraphics *pGraphics)=0
virtual bool Create(const SalBitmap &rSalBmp, vcl::PixelFormat eNewPixelFormat)=0
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:20
const sal_uLong nVCLLut[256]
const sal_uLong nVCLBLut[6]
const sal_uLong nVCLGLut[6]
const sal_uLong nVCLRLut[6]
const sal_uLong nVCLDitherLut[256]
sal_uIntPtr sal_uLong
unsigned char sal_uInt8