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