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>
26 #include <vcl/BitmapAccessMode.hxx>
27 #include <vcl/BitmapBuffer.hxx>
29 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
30 
31 struct BitmapBuffer;
32 class Color;
33 class SalGraphics;
34 class BitmapPalette;
35 struct BitmapSystemData;
36 enum class BmpScaleFlag;
37 
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 ];
43 
45 {
46 public:
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 
71  virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
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 
100  void GetChecksum(BitmapChecksum& rChecksum) const
101  {
102  updateChecksum();
103  if (!mbChecksumValid)
104  rChecksum = 0; // back-compat
105  else
106  rChecksum = mnChecksum;
107  }
108 
110  {
111  mbChecksumValid = false;
112  }
113 
114 protected:
117 
118 protected:
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
122  {
123  A8,
124  RGBA,
125  BGRA,
126  LAST = BGRA
127  };
128  static std::unique_ptr< sal_uInt8[] > convertDataBitCount( const sal_uInt8* src,
129  int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette,
130  BitConvert type );
131 };
132 
133 #endif
134 
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
PixelFormat
Pixel format of the bitmap in bits per pixel.
Definition: BitmapTypes.hxx:19
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
virtual bool AlphaBlendWith(const SalBitmap &)
Definition: salbmp.hxx:95
void InvalidateChecksum()
Definition: salbmp.hxx:109
bool mbChecksumValid
Definition: salbmp.hxx:116
const sal_uLong nVCLBLut[6]
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
sal_uIntPtr sal_uLong
BitmapChecksum mnChecksum
Definition: salbmp.hxx:115
virtual bool ConvertToGreyscale()
Definition: salbmp.hxx:81
virtual bool InterpretAs8Bit()
Definition: salbmp.hxx:85
void GetChecksum(BitmapChecksum &rChecksum) const
Definition: salbmp.hxx:100
SalBitmap()
Definition: salbmp.hxx:48
const sal_uLong nVCLLut[256]
BitmapAccessMode
const sal_uLong nVCLGLut[6]
virtual bool Erase(const Color &)
Definition: salbmp.hxx:90
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
unsigned char sal_uInt8
const sal_uLong nVCLRLut[6]
const sal_uLong nVCLDitherLut[256]