1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
35 struct BitmapSystemData
;
36 enum class BmpScaleFlag
;
38 class VCL_PLUGIN_PUBLIC SalBitmap
42 typedef BitmapChecksum ChecksumType
;
44 SalBitmap() : mbChecksumValid(false) {}
47 virtual bool Create( const Size
& rSize
,
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
,
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
78 rChecksum
= mnChecksum
;
79 return mbChecksumValid
;
82 virtual void InvalidateChecksum()
84 mbChecksumValid
= false;
88 ChecksumType mnChecksum
;
92 virtual void updateChecksum() const
97 ChecksumType nCrc
= 0;
98 SalBitmap
* pThis
= const_cast<SalBitmap
*>(this);
99 BitmapBuffer
* pBuf
= pThis
->AcquireBuffer(BITMAP_READ_ACCESS
);
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;
109 pThis
->mbChecksumValid
= false;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */