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 
85  void GetChecksum(BitmapChecksum& rChecksum) const
86  {
87  updateChecksum();
88  if (!mbChecksumValid)
89  rChecksum = 0; // back-compat
90  else
91  rChecksum = mnChecksum;
92  }
93 
95  {
96  mbChecksumValid = false;
97  }
98 
99 protected:
102 
103 protected:
104  virtual void updateChecksum() const
105  {
106  if (mbChecksumValid)
107  return;
108 
109  BitmapChecksum nCrc = 0;
110  SalBitmap* pThis = const_cast<SalBitmap*>(this);
112  if (pBuf)
113  {
114  nCrc = pBuf->maPalette.GetChecksum();
115  nCrc = vcl_get_checksum(nCrc, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
117  pThis->mnChecksum = nCrc;
118  pThis->mbChecksumValid = true;
119  }
120  else
121  {
122  pThis->mbChecksumValid = false;
123  }
124  }
125 
126 
127 };
128 
129 #endif
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_uInt64 BitmapChecksum
Definition: checksum.hxx:30
BitmapChecksum GetChecksum() const
void InvalidateChecksum()
Definition: salbmp.hxx:94
bool mbChecksumValid
Definition: salbmp.hxx:101
const sal_uLong nVCLBLut[6]
sal_uIntPtr sal_uLong
BitmapChecksum mnChecksum
Definition: salbmp.hxx:100
BitmapChecksum vcl_get_checksum(BitmapChecksum Checksum, const void *Data, sal_uInt32 DatLen)
Definition: checksum.hxx:72
virtual bool ConvertToGreyscale()
Definition: salbmp.hxx:80
void GetChecksum(BitmapChecksum &rChecksum) const
Definition: salbmp.hxx:85
SalBitmap()
Definition: salbmp.hxx:47
const sal_uLong nVCLLut[256]
BitmapAccessMode
virtual void updateChecksum() const
Definition: salbmp.hxx:104
sal_uInt8 * mpBits
BmpScaleFlag
Definition: bitmap.hxx:48
const sal_uLong nVCLGLut[6]
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
unsigned char sal_uInt8
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
const sal_uLong nVCLRLut[6]
BitmapPalette maPalette
virtual void ReleaseBuffer(BitmapBuffer *pBuffer, BitmapAccessMode nMode)=0
const sal_uLong nVCLDitherLut[256]
virtual BitmapBuffer * AcquireBuffer(BitmapAccessMode nMode)=0