-
Notifications
You must be signed in to change notification settings - Fork 0
/
Image.h
38 lines (31 loc) · 908 Bytes
/
Image.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef _IMAGE_H_
#define _IMAGE_H_
#include <cstdio>
#include <cstdlib>
#include "defs.h"
//
// Access the color using either individual component names
// or the channel array.
//
typedef union Color
{
struct
{
unsigned char red;
unsigned char grn;
unsigned char blu;
};
unsigned char channel[3];
} Color;
/* This class is provided to you for defining an image as a variable, manipulate it easily, and save it as a ppm file. */
class Image
{
public:
Color** data; // Image data
int width; // Image width
int height; // Image height
Image(int width, int height); // Constructor
void setPixelValue(int col, int row, const Color& color); // Sets the value of the pixel at the given column and row
void saveImage(const char *imageName) const; // Takes the image name as a file and saves it as a ppm file.
};
#endif