]>
Dogcows Code - chaz/rasterize/blob - raster.hh
3 * CS5600 University of Utah
5 * mcgarvey@eng.utah.edu
17 * A pixel map for storing and manipulating a 2D grid of color values.
19 typedef struct raster raster_t
;
23 * Create a new raster on the heap.
25 raster_t
* raster_alloc(int width
, int height
, color_t fill
);
28 * Free up the memory associated with the raster.
30 void raster_destroy(raster_t
* p
);
34 * Get the color value at a particular point.
36 color_t
* raster_color(const raster_t
* p
, int x
, int y
);
39 * Get the color value at the given texture coordinates.
41 color_t
raster_uv(const raster_t
* p
, vec_t uv
);
44 * Get the width of the raster.
46 int raster_width(const raster_t
* p
);
49 * Get the height of the raster.
51 int raster_height(const raster_t
* p
);
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.
57 void* raster_data(const raster_t
* p
);
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.
65 void raster_viewport(raster_t
* p
, int x
, int y
, int width
, int height
);
69 * Save the raster to a PPM file.
71 int raster_export_ppm(const raster_t
* p
, const char* filename
);
74 * Save the raster to a BMP file.
76 int raster_export_bmp(const raster_t
* p
, const char* filename
);
80 * Load the raster from an image file. The file extension is used to
81 * determine which importer is actually called.
83 raster_t
* raster_import(const char* filename
);
86 * Load the raster from a PPM file.
88 raster_t
* raster_import_ppm(const char* filename
);
91 * Load the raster from a BMP file.
93 raster_t
* raster_import_bmp(const char* filename
);
97 * Fill the entire raster with a solid color and reset the raster statistics.
99 void raster_clear(raster_t
* p
, color_t fill
);
102 #endif // _RASTER_HH_
This page took 0.041847 seconds and 5 git commands to generate.