xref: /aoo42x/main/vcl/inc/image.h (revision 2123d757)
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_H
25 #define _SV_IMAGE_H
26 
27 #include <vcl/bitmapex.hxx>
28 
29 #include <hash_map>
30 
31 // ----------------
32 // - ImplImageBmp -
33 // ----------------
34 
35 class ImplImageBmp
36 {
37 public:
38 
39 				ImplImageBmp();
40 				~ImplImageBmp();
41 
42 	void		Create( long nItemWidth, long nItemHeight, sal_uInt16 nInitSize );
43 	void		Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight,sal_uInt16 nInitSize );
44 
45 	void		Expand( sal_uInt16 nGrowSize );
46 
47 	void		Replace( sal_uInt16 nPos, sal_uInt16 nSrcPos );
48 	void		Replace( sal_uInt16 nPos, const ImplImageBmp& rImageBmp, sal_uInt16 nSrcPos );
49 	void		Replace( sal_uInt16 nPos, const BitmapEx& rBmpEx );
50 
51     void        ReplaceColors( const Color* pSrcColors, const Color* pDstColors, sal_uIntPtr nColorCount );
52 	void		ColorTransform( BmpColorMode eColorMode );
53 	void        	Invert();
54 
55 	BitmapEx	GetBitmapEx( sal_uInt16 nPosCount, sal_uInt16* pPosAry ) const;
56 
57 	void		Draw( sal_uInt16 nPos, OutputDevice* pDev, const Point& rPos, sal_uInt16 nStyle, const Size* pSize = NULL );
58 
59 private:
60 
61 	BitmapEx	maBmpEx;
62 	BitmapEx	maDisabledBmpEx;
63 	BitmapEx*	mpDisplayBmp;
64 	Size		maSize;
65 	sal_uInt8*		mpInfoAry;
66 	sal_uInt16		mnSize;
67 
68 	void		ImplUpdateDisplayBmp( OutputDevice* pOutDev );
69 	void		ImplUpdateDisabledBmpEx( int nPos );
70 
71 private:    // prevent assignment and copy construction
72     ImplImageBmp( const ImplImageBmp& );
73     void operator=( const ImplImageBmp& );
74 };
75 
76 // --------------
77 // - ImageTypes -
78 // --------------
79 
80 enum ImageType { IMAGETYPE_BITMAP, IMAGETYPE_IMAGE };
81 
82 // -----------------
83 // - ImplImageList -
84 // -----------------
85 
86 struct ImageAryData
87 {
88 	::rtl::OUString	maName;
89 	// Images identified by either name, or by id
90 	sal_uInt16			mnId;
91 	BitmapEx        maBitmapEx;
92 
93 	ImageAryData();
94 	ImageAryData( const rtl::OUString &aName,
95 				  sal_uInt16 nId, const BitmapEx &aBitmap );
96 	ImageAryData( const ImageAryData& rData );
97 	~ImageAryData();
98 
IsLoadableImageAryData99 	bool IsLoadable() { return maBitmapEx.IsEmpty() && maName.getLength(); }
100 	void Load(const rtl::OUString &rPrefix);
101 
102 	ImageAryData&	operator=( const ImageAryData& rData );
103 };
104 
105 // ------------------------------------------------------------------------------
106 
107 struct ImplImageList
108 {
109     typedef std::vector<ImageAryData *> ImageAryDataVec;
110     typedef std::hash_map< rtl::OUString, ImageAryData *, rtl::OUStringHash >
111         ImageAryDataNameHash;
112 
113     ImageAryDataVec             maImages;
114     ImageAryDataNameHash        maNameHash;
115 	rtl::OUString               maPrefix;
116 	Size			            maImageSize;
117     sal_uIntPtr                       mnRefCount;
118 
119 	ImplImageList();
120 	ImplImageList( const ImplImageList &aSrc );
121 	~ImplImageList();
122 
123 	void AddImage( const ::rtl::OUString &aName,
124 				   sal_uInt16 nId, const BitmapEx &aBitmapEx );
125 	void RemoveImage( sal_uInt16 nPos );
126     sal_uInt16 GetImageCount() const;
127 };
128 
129 // --------------------
130 // - ImplImageRefData -
131 // --------------------
132 
133 struct ImplImageRefData
134 {
135 	ImplImageList*	mpImplData;
136 	sal_uInt16			mnIndex;
137 
ImplImageRefDataImplImageRefData138 					ImplImageRefData() {}	 // Um Warning zu umgehen
139 					~ImplImageRefData();
140 
141 	sal_Bool			IsEqual( const ImplImageRefData& rData );
142 };
143 
144 // ----------------
145 // - ImpImageData -
146 // ----------------
147 
148 struct ImplImageData
149 {
150 	ImplImageBmp*	mpImageBitmap;
151 	BitmapEx		maBmpEx;
152 
153 					ImplImageData( const BitmapEx& rBmpEx );
154 					~ImplImageData();
155 
156 	sal_Bool			IsEqual( const ImplImageData& rData );
157 };
158 
159 // -------------
160 // - ImplImage -
161 // -------------
162 
163 struct ImplImage
164 {
165 	sal_uIntPtr			mnRefCount;
166     // TODO: use inheritance to get rid of meType+mpData
167 	void*			mpData;
168 	ImageType		meType;
169 
170 					ImplImage();
171 					~ImplImage();
172 
173 private:    // prevent assignment and copy construction
174             ImplImage( const ImplImage&);
175     void    operator=( const ImplImage&);
176 };
177 
178 #endif // _SV_IMAGE_H
179