]> Dogcows Code - chaz/rasterize/blob - raster.hh
finishing fifth project
[chaz/rasterize] / raster.hh
1
2 /*
3 * CS5600 University of Utah
4 * Charles McGarvey
5 * mcgarvey@eng.utah.edu
6 */
7
8 #ifndef _RASTER_HH_
9 #define _RASTER_HH_
10
11 #include "color.hh"
12 #include "common.hh"
13 #include "vec.hh"
14
15
16 /*
17 * A pixel map for storing and manipulating a 2D grid of color values.
18 */
19 typedef struct raster raster_t;
20
21
22 /*
23 * Create a new raster on the heap.
24 */
25 raster_t* raster_alloc(int width, int height, color_t fill);
26
27 /*
28 * Free up the memory associated with the raster.
29 */
30 void raster_destroy(raster_t* p);
31
32
33 /*
34 * Get the color value at a particular point.
35 */
36 color_t* raster_color(const raster_t* p, int x, int y);
37
38 /*
39 * Get the color value at the given texture coordinates.
40 */
41 color_t raster_uv(const raster_t* p, vec_t uv);
42
43 /*
44 * Get the width of the raster.
45 */
46 int raster_width(const raster_t* p);
47
48 /*
49 * Get the height of the raster.
50 */
51 int raster_height(const raster_t* p);
52
53 /*
54 * Get a copy of the raw RGBA pixel data of the raster. The returned
55 * buffer is indeed a copy and must be freed when no longer needed.
56 */
57 void* raster_data(const raster_t* p);
58
59
60 /*
61 * Set the viewport rectangle. This effectively sets up a clipping rectangle
62 * where nothing is drawn outside of the rectangle. The default viewport is
63 * [0, 0, width, height], or the entire raster area.
64 */
65 void raster_viewport(raster_t* p, int x, int y, int width, int height);
66
67
68 /*
69 * Save the raster to a PPM file.
70 */
71 int raster_export_ppm(const raster_t* p, const char* filename);
72
73 /*
74 * Save the raster to a BMP file.
75 */
76 int raster_export_bmp(const raster_t* p, const char* filename);
77
78
79 /*
80 * Load the raster from an image file. The file extension is used to
81 * determine which importer is actually called.
82 */
83 raster_t* raster_import(const char* filename);
84
85 /*
86 * Load the raster from a PPM file.
87 */
88 raster_t* raster_import_ppm(const char* filename);
89
90 /*
91 * Load the raster from a BMP file.
92 */
93 raster_t* raster_import_bmp(const char* filename);
94
95
96 /*
97 * Fill the entire raster with a solid color and reset the raster statistics.
98 */
99 void raster_clear(raster_t* p, color_t fill);
100
101
102 #endif // _RASTER_HH_
103
This page took 0.039637 seconds and 4 git commands to generate.