cctools
bitmap.h
1 /*
2 Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3 Copyright (C) 2005- The University of Notre Dame
4 This software is distributed under the GNU General Public License.
5 See the file COPYING for details.
6 */
7 
8 #ifndef BITMAP_H
9 #define BITMAP_H
10 
11 struct bitmap *bitmap_create(int w, int h);
12 void bitmap_delete(struct bitmap *b);
13 
14 int bitmap_get(struct bitmap *b, int x, int y);
15 void bitmap_set(struct bitmap *b, int x, int y, int value);
16 int bitmap_width(struct bitmap *b);
17 int bitmap_height(struct bitmap *b);
18 void bitmap_reset(struct bitmap *b, int value);
19 int *bitmap_data(struct bitmap *b);
20 
21 void bitmap_rotate_clockwise(struct bitmap *s, struct bitmap *t);
22 void bitmap_rotate_counterclockwise(struct bitmap *s, struct bitmap *t);
23 
24 int bitmap_average(struct bitmap *s);
25 void bitmap_smooth(struct bitmap *s, struct bitmap *t, int msize);
26 void bitmap_subset(struct bitmap *s, int x, int y, struct bitmap *t);
27 void bitmap_convolve(struct bitmap *s, struct bitmap *t, int (*f) (int x));
28 void bitmap_copy(struct bitmap *s, struct bitmap *t);
29 
30 struct bitmap *bitmap_load_any(const char *path);
31 
32 struct bitmap *bitmap_load_raw(const char *file);
33 struct bitmap *bitmap_load_bmp(const char *file);
34 struct bitmap *bitmap_load_pcx(const char *file);
35 struct bitmap *bitmap_load_sgi_rgb(const char *file);
36 struct bitmap *bitmap_load_jpeg(const char *file);
37 
38 int bitmap_save_raw(struct bitmap *b, const char *file);
39 int bitmap_save_bmp(struct bitmap *b, const char *file);
40 int bitmap_save_jpeg(struct bitmap *b, const char *file);
41 
42 #ifndef MAKE_RGBA
43 
44 #define MAKE_RGBA(r,g,b,a) ( (((int)(a))<<24) | (((int)(r))<<16) | (((int)(g))<<8) | (((int)(b))<<0) )
45 #endif
46 
47 #ifndef GET_RED
48 
49 #define GET_RED(rgba) (( (rgba)>>16 ) & 0xff )
50 #endif
51 
52 #ifndef GET_GREEN
53 
54 #define GET_GREEN(rgba) (( (rgba)>>8 ) & 0xff )
55 #endif
56 
57 #ifndef GET_BLUE
58 
59 #define GET_BLUE(rgba) (( (rgba)>>0 ) & 0xff )
60 #endif
61 
62 #ifndef GET_ALPHA
63 
64 #define GET_ALPHA(rgba) (( (rgba)>>24 ) & 0xff)
65 #endif
66 
67 #endif