comparison gui/util/bitmap.c @ 33984:60449f4234f7

Add doxygen comments to bitmap.c and bitmap.h.
author ib
date Tue, 06 Sep 2011 15:10:01 +0000
parents 2218c589f9ab
children d99f341d8442
comparison
equal deleted inserted replaced
33983:2218c589f9ab 33984:60449f4234f7
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License along 14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., 15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 /**
20 * @file
21 * @brief Image loader and bitmap mask rendering
17 */ 22 */
18 23
19 #include <stdio.h> 24 #include <stdio.h>
20 #include <stdlib.h> 25 #include <stdlib.h>
21 #include <string.h> 26 #include <string.h>
28 #include "libavutil/common.h" 33 #include "libavutil/common.h"
29 #include "libavutil/intreadwrite.h" 34 #include "libavutil/intreadwrite.h"
30 #include "libvo/fastmemcpy.h" 35 #include "libvo/fastmemcpy.h"
31 #include "mp_msg.h" 36 #include "mp_msg.h"
32 37
38 /**
39 * @brief Read and decode a PNG file into bitmap data.
40 *
41 * @param fname filename (with path)
42 * @param img pointer suitable to store the image data
43 *
44 * @return 0 (ok), 1 (decoding error), 2 (open error), 3 (file too big),
45 * 4 (out of memory), 5 (avcodec alloc error)
46 */
33 static int pngRead(const char *fname, guiImage *img) 47 static int pngRead(const char *fname, guiImage *img)
34 { 48 {
35 FILE *file; 49 FILE *file;
36 long len; 50 long len;
37 void *data; 51 void *data;
134 av_free(data); 148 av_free(data);
135 149
136 return !(decode_ok && img->Bpp); 150 return !(decode_ok && img->Bpp);
137 } 151 }
138 152
153 /**
154 * @brief Convert a 24-bit color depth image into an 32-bit one.
155 *
156 * @param img image to be converted
157 *
158 * @return 1 (ok) or 0 (error)
159 *
160 * @note This is an in-place conversion, new memory will be allocated for @a img.
161 */
139 static int Convert24to32(guiImage *img) 162 static int Convert24to32(guiImage *img)
140 { 163 {
141 char *orgImage; 164 char *orgImage;
142 unsigned long i, c; 165 unsigned long i, c;
143 166
163 } 186 }
164 187
165 return 1; 188 return 1;
166 } 189 }
167 190
191 /**
192 * @brief Check whether a (PNG) file exists.
193 *
194 * @param fname filename (with path, but may lack extension)
195 *
196 * @return path including extension (ok) or NULL (not accessible)
197 */
168 static const char *fExist(const char *fname) 198 static const char *fExist(const char *fname)
169 { 199 {
170 static const char ext[][4] = { "png", "PNG" }; 200 static const char ext[][4] = { "png", "PNG" };
171 static char buf[512]; 201 static char buf[512];
172 unsigned int i; 202 unsigned int i;
182 } 212 }
183 213
184 return NULL; 214 return NULL;
185 } 215 }
186 216
217 /**
218 * @brief Read a PNG file.
219 *
220 * @param fname filename (with path, but may lack extension)
221 * @param img pointer suitable to store the image data
222 *
223 * @return 0 (ok), -1 (color depth too low), -2 (not accessible),
224 * -5 (#pngRead() error) or -8 (#Convert24to32() error)
225 */
187 int bpRead(const char *fname, guiImage *img) 226 int bpRead(const char *fname, guiImage *img)
188 { 227 {
189 int r; 228 int r;
190 229
191 fname = fExist(fname); 230 fname = fExist(fname);
209 return -8; 248 return -8;
210 249
211 return 0; 250 return 0;
212 } 251 }
213 252
253 /**
254 * @brief Free all memory allocated to an image and set all its pointers to NULL.
255 *
256 * @param img image to be freed
257 */
214 void bpFree(guiImage *img) 258 void bpFree(guiImage *img)
215 { 259 {
216 free(img->Image); 260 free(img->Image);
217 memset(img, 0, sizeof(*img)); 261 memset(img, 0, sizeof(*img));
218 } 262 }
219 263
264 /**
265 * @brief Render a bitmap mask for an image.
266 *
267 * @param in image to render a bitmap mask from
268 * @param out bitmap mask
269 *
270 * @return 1 (ok) or 0 (error)
271 */
220 int bpRenderMask(const guiImage *in, guiImage *out) 272 int bpRenderMask(const guiImage *in, guiImage *out)
221 { 273 {
222 uint32_t *buf; 274 uint32_t *buf;
223 unsigned long i; 275 unsigned long i;
224 int b = 0, c = 0; 276 int b = 0, c = 0;