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_ALPHA_HXX
21 #define INCLUDED_VCL_ALPHA_HXX
23 #include <sal/config.h>
27 #include <vcl/dllapi.h>
28 #include <vcl/bitmap.hxx>
32 class VCL_DLLPUBLIC AlphaMask final
: public Bitmap
37 explicit AlphaMask( const Bitmap
& rBitmap
);
38 AlphaMask( const AlphaMask
& rAlphaMask
);
39 AlphaMask( AlphaMask
&& rAlphaMask
);
40 explicit AlphaMask( const Size
& rSizePixel
, const sal_uInt8
* pEraseTransparency
= nullptr );
41 virtual ~AlphaMask() override
;
43 AlphaMask
& operator=( const Bitmap
& rBitmap
);
44 AlphaMask
& operator=( const AlphaMask
& rAlphaMask
) { return static_cast<AlphaMask
&>( Bitmap::operator=( rAlphaMask
) ); }
45 AlphaMask
& operator=( AlphaMask
&& rAlphaMask
) noexcept
{ return static_cast<AlphaMask
&>( Bitmap::operator=( std::move(rAlphaMask
) ) ); }
46 bool operator==( const AlphaMask
& rAlphaMask
) const { return Bitmap::operator==(rAlphaMask
); }
47 bool operator!=( const AlphaMask
& rAlphaMask
) const { return Bitmap::operator!=(rAlphaMask
); }
49 Bitmap
const & GetBitmap() const;
51 void Erase( sal_uInt8 cTransparency
);
52 void BlendWith(const Bitmap
& rOther
);
54 // check if alpha is used, returns true if at least one pixel has transparence
55 bool hasAlpha() const;
57 BitmapReadAccess
* AcquireAlphaReadAccess() { return Bitmap::AcquireReadAccess(); }
58 BitmapWriteAccess
* AcquireAlphaWriteAccess() { return Bitmap::AcquireWriteAccess(); }
60 void ReleaseAccess( BitmapReadAccess
* pAccess
);
62 typedef vcl::ScopedBitmapAccess
<BitmapReadAccess
, AlphaMask
, &AlphaMask::AcquireAlphaReadAccess
> ScopedReadAccess
;
64 using Bitmap::IsEmpty
;
67 friend class BitmapEx
;
68 friend class ::OutputDevice
;
69 friend bool VCL_DLLPUBLIC
ReadDIBBitmapEx(BitmapEx
& rTarget
, SvStream
& rIStm
, bool bFileHeader
, bool bMSOFormat
);
71 SAL_DLLPRIVATE
const Bitmap
& ImplGetBitmap() const;
72 SAL_DLLPRIVATE
void ImplSetBitmap( const Bitmap
& rBitmap
);
76 #endif // INCLUDED_VCL_ALPHA_HXX
78 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */