xref: /aoo42x/main/vcl/inc/vcl/alpha.hxx (revision 54628ca4)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_ALPHA_HXX
25 #define _SV_ALPHA_HXX
26 
27 #include <vcl/dllapi.h>
28 #include <vcl/bitmap.hxx>
29 
30 // -------------
31 // - AlphaMask -
32 // -------------
33 
34 class ImageList;
35 class BitmapEx;
36 
37 class VCL_DLLPUBLIC AlphaMask : private Bitmap
38 {
39 	friend class BitmapEx;
40 	friend class OutputDevice;
41 	friend VCL_DLLPUBLIC SvStream& operator<<( SvStream&, const ImageList& );
42 
43 private:
44 
45 	SAL_DLLPRIVATE const Bitmap&    ImplGetBitmap() const;
46 	SAL_DLLPRIVATE void             ImplSetBitmap( const Bitmap& rBitmap );
47 
48 public:
49 
50                             AlphaMask();
51 							AlphaMask( const Bitmap& rBitmap );
52                             AlphaMask( const AlphaMask& rAlphaMask );
53                             AlphaMask( const Size& rSizePixel, sal_uInt8* pEraseTransparency = NULL );
54                             ~AlphaMask();
55 
56     AlphaMask&				operator=( const Bitmap& rBitmap );
57 	AlphaMask&				operator=( const AlphaMask& rAlphaMask ) { return (AlphaMask&) Bitmap::operator=( rAlphaMask ); }
58 	sal_Bool					operator!() const { return Bitmap::operator!(); }
59     sal_Bool					operator==( const AlphaMask& rAlphaMask ) const { return Bitmap::operator==( rAlphaMask ); }
60     sal_Bool					operator!=( const AlphaMask& rAlphaMask ) const { return Bitmap::operator!=( rAlphaMask ); }
61 
62     const MapMode&			GetPrefMapMode() const { return Bitmap::GetPrefMapMode(); }
63     void					SetPrefMapMode( const MapMode& rMapMode ) { Bitmap::SetPrefMapMode( rMapMode ); }
64 
65     const Size&				GetPrefSize() const { return Bitmap::GetPrefSize(); }
66     void					SetPrefSize( const Size& rSize ) { Bitmap::SetPrefSize( rSize ); }
67 
68     Size					GetSizePixel() const { return Bitmap::GetSizePixel(); }
69 	void					SetSizePixel( const Size& rNewSize, sal_uInt32 nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE )
70     {
71         Bitmap::SetSizePixel( rNewSize, nScaleFlag );
72     }
73 
74     sal_uLong					GetSizeBytes() const { return Bitmap::GetSizeBytes(); }
75 	sal_uLong					GetChecksum() const { return Bitmap::GetChecksum(); }
76 
77 	Bitmap					GetBitmap() const;
78 
79 public:
80 
81     sal_Bool                    Crop( const Rectangle& rRectPixel );
82     sal_Bool                    Expand( sal_uLong nDX, sal_uLong nDY, sal_uInt8* pInitTransparency = NULL );
83     sal_Bool                    CopyPixel( const Rectangle& rRectDst, const Rectangle& rRectSrc, const AlphaMask* pAlphaSrc = NULL );
84     sal_Bool                    Erase( sal_uInt8 cTransparency );
85     sal_Bool                    Invert();
86     sal_Bool                    Mirror( sal_uLong nMirrorFlags );
87     sal_Bool                    Scale( const Size& rNewSize, sal_uInt32 nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE );
88     sal_Bool                    Scale( const double& rScaleX, const double& rScaleY, sal_uInt32 nScaleFlag = BMP_SCALE_FASTESTINTERPOLATE );
89     sal_Bool                    Rotate( long nAngle10, sal_uInt8 cFillTransparency );
90     sal_Bool                    Replace( const Bitmap& rMask, sal_uInt8 rReplaceTransparency );
91     sal_Bool                    Replace( sal_uInt8 cSearchTransparency, sal_uInt8 cReplaceTransparency, sal_uLong nTol = 0UL );
92     sal_Bool                    Replace( sal_uInt8* pSearchTransparencies, sal_uInt8* pReplaceTransparencies,
93 									 sal_uLong nColorCount, sal_uLong* pTols = NULL );
94 
95 public:
96 
97     BitmapReadAccess*		AcquireReadAccess() { return Bitmap::AcquireReadAccess(); }
98     BitmapWriteAccess*		AcquireWriteAccess() { return Bitmap::AcquireWriteAccess(); }
99     void					ReleaseAccess( BitmapReadAccess* pAccess );
100 
101 public:
102 
103     sal_Bool					Read( SvStream& rIStm, sal_Bool bFileHeader = sal_True ) { return Bitmap::Read( rIStm, bFileHeader ); }
104 	sal_Bool					Write( SvStream& rOStm, sal_Bool bCompressed = sal_True, sal_Bool bFileHeader = sal_True ) const { return Bitmap::Write( rOStm, bCompressed, bFileHeader ); }
105 
106 	friend VCL_DLLPUBLIC SvStream& operator<<( SvStream& rOStm, const BitmapEx& rBitmapEx );
107 	friend VCL_DLLPUBLIC SvStream& operator>>( SvStream& rIStm, BitmapEx& rBitmapEx );
108 };
109 
110 #endif // _SV_ALPHA_HXX
111