-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_ppm.hpp
More file actions
85 lines (65 loc) · 2.14 KB
/
Copy pathimage_ppm.hpp
File metadata and controls
85 lines (65 loc) · 2.14 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef IMAGE_PPM_HPP
#define IMAGE_PPM_HPP
#include <fstream>
#include <iostream>
#include <string>
#include "pixel.hpp"
class ImagePPM {
public:
// default constructor
//
// not tested but you are welcome to initialize (or not) member
// variables however you like in this function
ImagePPM() = default;
// overloaded constructor
//
// initialize the instance given the file at path. You may assume that
// path is always valid and that a file exists at path
ImagePPM(const std::string& path);
// copy constructor.
//
// should intialize the instance as DEEP COPY of source (meaning all
// values should be the same, but chaning source will not change
// anything in this instance, and vice versa)
ImagePPM(const ImagePPM& source);
// assignment operator
//
// should set the instance to be a DEEP COPY of source. Note that the
// current instance (this) already exists and you should be wary of
// leaks and the possiblity of null pointers
ImagePPM& operator=(const ImagePPM& source);
// destructor
//
// releases all heap memory used by the instance
~ImagePPM();
// returns the Pixel at row col. You may assume that row and col
// will always be within the bounds of image_
Pixel GetPixel(int row, int col) const;
// returns the width of the image
int GetWidth() const { return width_; };
// returns the height of the image
int GetHeight() const { return height_; };
// returns the max color value of the image
int GetMaxColorValue() const;
// outputs the image in plain PPM format to os
friend std::ostream& operator<<(std::ostream& os, const ImagePPM& image);
// fills in image using the input stream, is. the stream contains
// an image in plain PPM format
friend std::istream& operator>>(std::istream& is, ImagePPM& image);
/**
* Add any helper methods you may need
*/
void VSetImage(const int* seam);
void HSetImage(const int* seam);
private:
int height_ = 0;
int width_ = 0;
int max_color_value_ = 0;
Pixel** pixels_ = nullptr;
// given help function, "clears" the data of the instance
void Clear();
/**
* Add any helper methods you may need
*/
};
#endif