xref: /trunk/main/vcl/inc/vcl/image.hxx (revision 0d63794c)
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_IMAGE_HXX
25 #define _SV_IMAGE_HXX
26 
27 #include <vcl/dllapi.h>
28 #include <tools/gen.hxx>
29 #include <tools/resid.hxx>
30 #include <vcl/sv.h>
31 #include <vcl/bitmapex.hxx>
32 #include <com/sun/star/uno/Reference.hxx>
33 
34 #include <vector>
35 
36 struct ImplImage;
37 struct ImplImageList;
38 namespace com { namespace sun { namespace star { namespace graphic { class XGraphic;} } } }
39 
40 // -----------
41 // - Defines -
42 // -----------
43 
44 #define IMAGE_STDBTN_COLOR			Color( 0xC0, 0xC0, 0xC0 )
45 #define IMAGELIST_IMAGE_NOTFOUND	((sal_uInt16)0xFFFF)
46 
47 // -----------------------
48 // - ImageColorTransform -
49 // -----------------------
50 
51 enum ImageColorTransform
52 {
53     IMAGECOLORTRANSFORM_NONE = 0,
54     IMAGECOLORTRANSFORM_HIGHCONTRAST = 1,
55     IMAGECOLORTRANSFORM_MONOCHROME_BLACK = 2,
56     IMAGECOLORTRANSFORM_MONOCHROME_WHITE = 3
57 };
58 
59 // ---------
60 // - Image -
61 // ---------
62 
63 class VCL_DLLPUBLIC Image
64 {
65 	friend class ImageList;
66 	friend class OutputDevice;
67 
68 public:
69 					Image();
70 					Image( const ResId& rResId );
71 					Image( const Image& rImage );
72 					Image( const BitmapEx& rBitmapEx );
73 					Image( const Bitmap& rBitmap );
74 					Image( const Bitmap& rBitmap, const Bitmap& rMaskBitmap );
75 					Image( const Bitmap& rBitmap, const Color& rColor );
76 					Image( const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >& rxGraphic );
77 					~Image();
78 
79 	Size			GetSizePixel() const;
80 
81 	BitmapEx		GetBitmapEx() const;
82 	::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > GetXGraphic() const;
83 
84     Image           GetColorTransformedImage( ImageColorTransform eColorTransform ) const;
85     static void     GetColorTransformArrays( ImageColorTransform eColorTransform, Color*& rpSrcColor, Color*& rpDstColor, sal_uLong& rColorCount );
86 
87     void            Invert();
88 
operator !() const89 	sal_Bool			operator!() const { return( !mpImplData ? true : false ); }
90 	Image&			operator=( const Image& rImage );
91 	sal_Bool			operator==( const Image& rImage ) const;
operator !=(const Image & rImage) const92 	sal_Bool			operator!=( const Image& rImage ) const { return !(Image::operator==( rImage )); }
93 
94 private:
95 
96 	ImplImage*		       mpImplData;
97 
98 	SAL_DLLPRIVATE void    ImplInit( const BitmapEx& rBmpEx );
99 };
100 
101 // -------------
102 // - ImageList -
103 // -------------
104 
105 class VCL_DLLPUBLIC ImageList
106 {
107 public:
108 					ImageList( sal_uInt16 nInit = 8, sal_uInt16 nGrow = 4 );
109 					ImageList( const ResId& rResId );
110 					ImageList( const ::std::vector< ::rtl::OUString >& rNameVector,
111 							   const ::rtl::OUString& rPrefix,
112 							   const Color* pMaskColor = NULL );
113 					ImageList( const ImageList& rImageList );
114 					~ImageList();
115 
116 	void				Clear();
117 	void            		InsertFromHorizontalStrip( const BitmapEx &rBitmapEx,
118 								   const std::vector< rtl::OUString > &rNameVector );
119 	void            		InsertFromHorizontalBitmap( const ResId& rResId,
120 								    sal_uInt16       nCount,
121 								    const Color *pNonAlphaMaskColor,
122 								    const Color *pSearchColors = NULL,
123 								    const Color *pReplaceColors = NULL,
124 								    sal_uLong        nColorCount = 0);
125 	BitmapEx		GetAsHorizontalStrip() const;
126 	sal_uInt16			GetImageCount() const;
127 	Size			GetImageSize() const;
128 
129 	void			AddImage( sal_uInt16 nNewId, const Image& rImage );
130 	void			AddImage( const ::rtl::OUString& rImageName, const Image& rImage );
131 
132 	void			ReplaceImage( sal_uInt16 nId, const Image& rImage );
133 	void			ReplaceImage( const ::rtl::OUString& rImageName, const Image& rImage );
134 
135 	void			ReplaceImage( sal_uInt16 nId, sal_uInt16 nReplaceId );
136 	void			ReplaceImage( const ::rtl::OUString& rImageName, const ::rtl::OUString& rReplaceName );
137 
138 	void			RemoveImage( sal_uInt16 nId );
139 	void			RemoveImage( const ::rtl::OUString& rImageName );
140 
141 	Image			GetImage( sal_uInt16 nId ) const;
142 	Image			GetImage( const ::rtl::OUString& rImageName ) const;
143 
144 	sal_uInt16			GetImagePos( sal_uInt16 nId ) const;
145 	bool			HasImageAtPos( sal_uInt16 nId ) const;
146 	sal_uInt16			GetImagePos( const ::rtl::OUString& rImageName ) const;
147 
148 	sal_uInt16			GetImageId( sal_uInt16 nPos ) const;
149 	void			GetImageIds( ::std::vector< sal_uInt16 >& rIds ) const;
150 
151 	::rtl::OUString	GetImageName( sal_uInt16 nPos ) const;
152 	void			GetImageNames( ::std::vector< ::rtl::OUString >& rNames ) const;
153 
154 	ImageList&		operator=( const ImageList& rImageList );
155 	sal_Bool			operator==( const ImageList& rImageList ) const;
operator !=(const ImageList & rImageList) const156 	sal_Bool			operator!=( const ImageList& rImageList ) const { return !(ImageList::operator==( rImageList )); }
157 
158 private:
159 
160 	ImplImageList*	mpImplData;
161 	sal_uInt16			mnInitSize;
162 	sal_uInt16			mnGrowSize;
163 
164     SAL_DLLPRIVATE void    ImplInitBitmapEx( const ::rtl::OUString& rUserImageName,
165                                              const ::std::vector< ::rtl::OUString >& rImageNames,
166                                              const ::rtl::OUString& rSymbolsStyle,
167                                              BitmapEx& rBmpEx,
168                                              const Color* pMaskColor ) const;
169 	SAL_DLLPRIVATE void    ImplInit( sal_uInt16 nItems, const Size &rSize );
170 	SAL_DLLPRIVATE sal_uInt16  ImplGetImageId( const ::rtl::OUString& rImageName ) const;
171 	SAL_DLLPRIVATE void    ImplMakeUnique();
172 };
173 
174 #endif	// _SV_IMAGE_HXX
175