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