xref: /aoo41x/main/vcl/inc/image.h (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_IMAGE_H
29 #define _SV_IMAGE_H
30 
31 #include <vcl/bitmapex.hxx>
32 
33 #include <hash_map>
34 
35 // ----------------
36 // - ImplImageBmp -
37 // ----------------
38 
39 class ImplImageBmp
40 {
41 public:
42 
43 				ImplImageBmp();
44 				~ImplImageBmp();
45 
46 	void		Create( long nItemWidth, long nItemHeight, sal_uInt16 nInitSize );
47 	void		Create( const BitmapEx& rBmpEx, long nItemWidth, long nItemHeight,sal_uInt16 nInitSize );
48 
49 	void		Expand( sal_uInt16 nGrowSize );
50 
51 	void		Replace( sal_uInt16 nPos, sal_uInt16 nSrcPos );
52 	void		Replace( sal_uInt16 nPos, const ImplImageBmp& rImageBmp, sal_uInt16 nSrcPos );
53 	void		Replace( sal_uInt16 nPos, const BitmapEx& rBmpEx );
54 
55     void        ReplaceColors( const Color* pSrcColors, const Color* pDstColors, sal_uIntPtr nColorCount );
56 	void		ColorTransform( BmpColorMode eColorMode );
57 	void        	Invert();
58 
59 	BitmapEx	GetBitmapEx( sal_uInt16 nPosCount, sal_uInt16* pPosAry ) const;
60 
61 	void		Draw( sal_uInt16 nPos, OutputDevice* pDev, const Point& rPos, sal_uInt16 nStyle, const Size* pSize = NULL );
62 
63 private:
64 
65 	BitmapEx	maBmpEx;
66 	BitmapEx	maDisabledBmpEx;
67 	BitmapEx*	mpDisplayBmp;
68 	Size		maSize;
69 	sal_uInt8*		mpInfoAry;
70 	sal_uInt16		mnSize;
71 
72 	void		ImplUpdateDisplayBmp( OutputDevice* pOutDev );
73 	void		ImplUpdateDisabledBmpEx( int nPos );
74 
75 private:    // prevent assignment and copy construction
76     ImplImageBmp( const ImplImageBmp& );
77     void operator=( const ImplImageBmp& );
78 };
79 
80 // --------------
81 // - ImageTypes -
82 // --------------
83 
84 enum ImageType { IMAGETYPE_BITMAP, IMAGETYPE_IMAGE };
85 
86 // -----------------
87 // - ImplImageList -
88 // -----------------
89 
90 struct ImageAryData
91 {
92 	::rtl::OUString	maName;
93 	// Images identified by either name, or by id
94 	sal_uInt16			mnId;
95 	BitmapEx        maBitmapEx;
96 
97 	ImageAryData();
98 	ImageAryData( const rtl::OUString &aName,
99 				  sal_uInt16 nId, const BitmapEx &aBitmap );
100 	ImageAryData( const ImageAryData& rData );
101 	~ImageAryData();
102 
103 	bool IsLoadable() { return maBitmapEx.IsEmpty() && maName.getLength(); }
104 	void Load(const rtl::OUString &rPrefix);
105 
106 	ImageAryData&	operator=( const ImageAryData& rData );
107 };
108 
109 // ------------------------------------------------------------------------------
110 
111 struct ImplImageList
112 {
113     typedef std::vector<ImageAryData *> ImageAryDataVec;
114     typedef std::hash_map< rtl::OUString, ImageAryData *, rtl::OUStringHash >
115         ImageAryDataNameHash;
116 
117     ImageAryDataVec             maImages;
118     ImageAryDataNameHash        maNameHash;
119 	rtl::OUString               maPrefix;
120 	Size			            maImageSize;
121     sal_uIntPtr                       mnRefCount;
122 
123 	ImplImageList();
124 	ImplImageList( const ImplImageList &aSrc );
125 	~ImplImageList();
126 
127 	void AddImage( const ::rtl::OUString &aName,
128 				   sal_uInt16 nId, const BitmapEx &aBitmapEx );
129 	void RemoveImage( sal_uInt16 nPos );
130     sal_uInt16 GetImageCount() const;
131 };
132 
133 // --------------------
134 // - ImplImageRefData -
135 // --------------------
136 
137 struct ImplImageRefData
138 {
139 	ImplImageList*	mpImplData;
140 	sal_uInt16			mnIndex;
141 
142 					ImplImageRefData() {}	 // Um Warning zu umgehen
143 					~ImplImageRefData();
144 
145 	sal_Bool			IsEqual( const ImplImageRefData& rData );
146 };
147 
148 // ----------------
149 // - ImpImageData -
150 // ----------------
151 
152 struct ImplImageData
153 {
154 	ImplImageBmp*	mpImageBitmap;
155 	BitmapEx		maBmpEx;
156 
157 					ImplImageData( const BitmapEx& rBmpEx );
158 					~ImplImageData();
159 
160 	sal_Bool			IsEqual( const ImplImageData& rData );
161 };
162 
163 // -------------
164 // - ImplImage -
165 // -------------
166 
167 struct ImplImage
168 {
169 	sal_uIntPtr			mnRefCount;
170     // TODO: use inheritance to get rid of meType+mpData
171 	void*			mpData;
172 	ImageType		meType;
173 
174 					ImplImage();
175 					~ImplImage();
176 
177 private:    // prevent assignment and copy construction
178             ImplImage( const ImplImage&);
179     void    operator=( const ImplImage&);
180 };
181 
182 #endif // _SV_IMAGE_H
183