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>
28 #include <com/sun/star/rendering/XBitmapCanvas.hpp>
29 
30 struct BitmapBuffer;
31 class Color;
32 class SalGraphics;
33 class BitmapPalette;
34 struct BitmapSystemData;
35 enum class BmpScaleFlag;
36 
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 ];
42 
44 {
45 public:
46 
48  : mnChecksum(0)
49  , mbChecksumValid(false)
50  {
51  }
52 
53  virtual ~SalBitmap();
54 
55  virtual bool Create( const Size& rSize,
56  sal_uInt16 nBitCount,
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,
64  Size& rSize,
65  bool bMask = false ) = 0;
66  virtual void Destroy() = 0;
67  virtual Size GetSize() const = 0;
68  virtual sal_uInt16 GetBitCount() const = 0;
69 
70  virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
71  virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
72  virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
73 
74  virtual bool ScalingSupported() const = 0;
75  virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
76  void DropScaledCache();
77 
78  virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uInt8 nTol ) = 0;
79 
80  virtual bool ConvertToGreyscale()
81  {
82  return false;
83  }
84  virtual bool InterpretAs8Bit()
85  {
86  return false;
87  }
88 
89  void GetChecksum(BitmapChecksum& rChecksum) const
90  {
91  updateChecksum();
92  if (!mbChecksumValid)
93  rChecksum = 0; // back-compat
94  else
95  rChecksum = mnChecksum;
96  }
97 
99  {
100  mbChecksumValid = false;
101  }
102 
103 protected:
106 
107 protected:
108  virtual void updateChecksum() const;
109  // helper function to convert data in 1,2,4 bpp formats to a 8/24/32bpp format
110  enum class BitConvert
111  {
112  A8,
113  RGB,
114  BGR,
115  RGBA,
116  BGRA
117  };
118  static std::unique_ptr< sal_uInt8[] > convertDataBitCount( const sal_uInt8* src,
119  int width, int height, int bitCount, int bytesPerRow, const BitmapPalette& palette,
120  BitConvert type );
121 };
122 
123 #endif
124 
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
void InvalidateChecksum()
Definition: salbmp.hxx:98
bool mbChecksumValid
Definition: salbmp.hxx:105
const sal_uLong nVCLBLut[6]
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
sal_uIntPtr sal_uLong
BitmapChecksum mnChecksum
Definition: salbmp.hxx:104
virtual bool ConvertToGreyscale()
Definition: salbmp.hxx:80
virtual bool InterpretAs8Bit()
Definition: salbmp.hxx:84
void GetChecksum(BitmapChecksum &rChecksum) const
Definition: salbmp.hxx:89
SalBitmap()
Definition: salbmp.hxx:47
const sal_uLong nVCLLut[256]
BitmapAccessMode
BmpScaleFlag
Definition: bitmap.hxx:48
const sal_uLong nVCLGLut[6]
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
unsigned char sal_uInt8
const sal_uLong nVCLRLut[6]
const sal_uLong nVCLDitherLut[256]