Branch libreoffice-5-0-4
[LibreOffice.git] / vcl / inc / salbmp.hxx
blobbbd0ee13cac3df684d797a9a65c6e4a5cd2622f5
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/dllapi.h>
26 #include <vcl/checksum.hxx>
27 #include <vcl/salbtype.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 class VCL_PLUGIN_PUBLIC SalBitmap
40 public:
42 typedef BitmapChecksum ChecksumType;
44 SalBitmap() : mbChecksumValid(false) {}
45 virtual ~SalBitmap();
47 virtual bool Create( const Size& rSize,
48 sal_uInt16 nBitCount,
49 const BitmapPalette& rPal ) = 0;
50 virtual bool Create( const SalBitmap& rSalBmp ) = 0;
51 virtual bool Create( const SalBitmap& rSalBmp,
52 SalGraphics* pGraphics ) = 0;
53 virtual bool Create( const SalBitmap& rSalBmp,
54 sal_uInt16 nNewBitCount ) = 0;
55 virtual bool Create( const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas >& rBitmapCanvas,
56 Size& rSize,
57 bool bMask = false ) = 0;
58 virtual void Destroy() = 0;
59 virtual Size GetSize() const = 0;
60 virtual sal_uInt16 GetBitCount() const = 0;
62 virtual BitmapBuffer* AcquireBuffer( BitmapAccessMode nMode ) = 0;
63 virtual void ReleaseBuffer( BitmapBuffer* pBuffer, BitmapAccessMode nMode ) = 0;
64 virtual bool GetSystemData( BitmapSystemData& rData ) = 0;
66 virtual bool Crop( const Rectangle& rRectPixel ) = 0;
67 virtual bool Erase( const Color& rFillColor ) = 0;
68 virtual bool Scale( const double& rScaleX, const double& rScaleY, BmpScaleFlag nScaleFlag ) = 0;
69 virtual bool Replace( const Color& rSearchColor, const Color& rReplaceColor, sal_uLong nTol ) = 0;
72 virtual bool GetChecksum(ChecksumType& rChecksum) const
74 updateChecksum();
75 if (!mbChecksumValid)
76 rChecksum = 0;
77 else
78 rChecksum = mnChecksum;
79 return mbChecksumValid;
82 virtual void InvalidateChecksum()
84 mbChecksumValid = false;
87 protected:
88 ChecksumType mnChecksum;
89 bool mbChecksumValid;
91 protected:
92 virtual void updateChecksum() const
94 if (mbChecksumValid)
95 return;
97 ChecksumType nCrc = 0;
98 SalBitmap* pThis = const_cast<SalBitmap*>(this);
99 BitmapBuffer* pBuf = pThis->AcquireBuffer(BITMAP_READ_ACCESS);
100 if (pBuf)
102 nCrc = vcl_get_checksum(0, pBuf->mpBits, pBuf->mnScanlineSize * pBuf->mnHeight);
103 pThis->ReleaseBuffer(pBuf, BITMAP_READ_ACCESS);
104 pThis->mnChecksum = nCrc;
105 pThis->mbChecksumValid = true;
107 else
109 pThis->mbChecksumValid = false;
116 #endif
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */