The Fib multimedia system
Fib is a system for storing multimedia data (like images or films).
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
fipImage.h
Go to the documentation of this file.
1 /**
2  * @file fipImage
3  * file name: fipImage.h
4  * @author Betti Oesterholz
5  * @date 14.05.2011
6  * @mail webmaster@BioKom.info
7  *
8  * System: C++
9  *
10  * This file specifies class to wrap the FreeImage functionality for
11  * the Fib-system.
12  * Copyright (C) @c GPL3 2010 Betti Oesterholz
13  *
14  * This program is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License (GPL) as
16  * published by the Free Software Foundation, either version 3 of the
17  * License, or any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  *
28  * This file specifies class to wrap the FreeImage functionality for
29  * the Fib-system.
30  *
31  */
32 /*
33 History:
34 14.05.2011 Oesterholz created
35 22.03.2012 Oesterholz setTransparent() implemented
36 14.04.2012 Oesterholz isTransparent() and unload() implemented
37 */
38 
39 #include "FreeImage.h"
40 
41 
42 #ifndef ___C_FIP_IMAGE_H__
43 #define ___C_FIP_IMAGE_H__
44 
45 
46 /**
47  * @class fipImage
48  * Warper class for FreeImage image data
49  */
50 class fipImage{
51 private:
52 
53  /**
54  * This flag is true if the FreeImage system was initialised, else false.
55  */
56  static bool bFreeImageInitialised;
57 
58  /**
59  * The counter for the number of instances of this class.
60  * If no instance exists anymore the FreeImage system will be
61  * deinitialised.
62  */
63  static unsigned long ulImageInstances;
64 
65  /**
66  * The pointer to the data of the image.
67  */
68  FIBITMAP * pImageData;
69 
70 public:
71 
72  /**
73  * standard constructor of an fipImage object
74  */
75  fipImage();
76 
77  /**
78  * parameter constructor of an fipImage object
79  *
80  * @param type the type of the image of the fipImage to create
81  * @param ulWidth the width of the image (in points) of the fipImage
82  * to create
83  * @param ulHeight the height of the image (in points) of the fipImage
84  * to create
85  * @param uiBitsPerPixel the number of bits per pixel for the color of
86  * the fipImage to create
87  */
88  fipImage( FREE_IMAGE_TYPE type, const unsigned long ulWidth, const unsigned long ulHeight, const unsigned int uiBitsPerPixel );
89 
90  /**
91  * copy constructor
92  *
93  * @param inFipImage the fip image to copy
94  */
95  fipImage( const fipImage & inFipImage );
96 
97  /**
98  * destructor
99  */
100  ~fipImage();
101 
102 
103  /**
104  * @return the width of the image (in points)
105  */
106  unsigned long getWidth() const;
107 
108  /**
109  * @return the height of the image (in points)
110  */
111  unsigned long getHeight() const;
112 
113  /**
114  * @return the number of bits per pixel for the color
115  */
116  unsigned int getBitsPerPixel() const;
117 
118  /**
119  * @return true if the picture is in grayscale else false
120  */
121  bool isGrayscale() const;
122 
123  /**
124  * @return the color type of the picture
125  */
126  FREE_IMAGE_COLOR_TYPE getColorType() const;
127 
128  /**
129  * @return the number of entries in the color palette
130  */
131  unsigned long getPaletteSize() const;
132 
133  /**
134  * @return the array of the color palette (every entry is an color)
135  */
136  RGBQUAD * getPalette() const;
137 
138  /**
139  * @return if the picture has an background color, else false
140  */
141  bool hasFileBkColor() const;
142 
143  /**
144  * This method returns the background color value of the picture.
145  *
146  * @param colorValue a pointer to the color value field wher to store
147  * the background color value
148  * @return true if the background color was evalued, else false
149  */
150  bool getFileBkColor( RGBQUAD * colorValue ) const;
151 
152  /**
153  * This method sets the background color value of the picture.
154  *
155  * @param colorValue the color value to set
156  * @return true if the background color was set, else false
157  */
158  bool setFileBkColor( RGBQUAD * colorValue );
159 
160  /**
161  * This method returns the color on the given position.
162  *
163  * @param ulX the horizontal (x) position, from which to get the color
164  * @param ulY the vertical (y) position, from which to get the color
165  * @param colorValue a pointer to the color value field wher to store
166  * the color value
167  * @return true if pixel color was evalued, else false
168  */
169  bool getPixelColor( const unsigned long ulX, const unsigned long ulY, RGBQUAD * colorValue ) const;
170 
171  /**
172  * This method sets the color on the given position.
173  *
174  * @param ulX the horizontal (x) position, on which to set the color
175  * @param ulY the vertical (y) position, on which to set the color
176  * @param colorValue a pointer to the color value field to set
177  * @return true if pixel color was set, else false
178  */
179  bool setPixelColor( const unsigned long ulX, const unsigned long ulY, RGBQUAD * colorValue );
180 
181  /**
182  * This method returns the color index value on the given position.
183  *
184  * @param ulX the horizontal (x) position, from which to get the color index
185  * @param ulY the vertical (y) position, from which to get the color index
186  * @param colorValue a pointer to the color index value field wher to
187  * store the color index value
188  * @return true if pixel color index was evalued, else false
189  */
190  bool getPixelIndex( const unsigned long ulX, const unsigned long ulY, BYTE * colorIndexValue ) const;
191 
192  /**
193  * This method sets the color index value on the given position.
194  *
195  * @param ulX the horizontal (x) position, on which to set the color index
196  * @param ulY the vertical (y) position, on which to set the color index
197  * @param colorValue a pointer to the color index value field to set
198  * @return true if pixel color index was set, else false
199  */
200  bool setPixelIndex( const unsigned long ulX, const unsigned long ulY, BYTE * colorIndexValue );
201 
202  /**
203  * This method converts the image to grayscale.
204  *
205  * @return true if the image was converted to grayscale, else false
206  */
207  bool convertToGrayscale();
208 
209  /**
210  * @return true if transparency is enabled, else false
211  */
212  bool isTransparent();
213 
214  /**
215  * This method sets if transparency should be enabled for the image.
216  *
217  * @param bEnabled if transparency should be enabled
218  */
219  void setTransparent( bool bEnabled );
220 
221  /**
222  * This method loads the image from an given file.
223  * The image type will determined by the file ending and its
224  * contained data.
225  *
226  * @param szFile the path of the image file to load
227  * @return true if the image data was loaded, else false
228  */
229  bool load( const char * szFile );
230 
231  /**
232  * Deletes previously loaded image data.
233  */
234  void unload();
235 
236  /**
237  * This method saves the image to an given file.
238  * The image type will determined by the file ending.
239  *
240  * @param szFile the path of the image file to save
241  * @return true if the image data was saved, else false
242  */
243  bool save( const char * szFile ) const;
244 
245 
246 };//end class fipImage
247 
248 
249 
250 #endif //___C_FIP_IMAGE_H__
251 
252