Browse Source

[PPM] Use existing constant magic number instead of specifying it everywhere manually

master
Unbewohnte 3 years ago
parent
commit
d7470c7157
  1. 6
      src/pnm.cpp

6
src/pnm.cpp

@ -29,6 +29,8 @@ class Color {
public: public:
Color() {} Color() {}
~Color() {} ~Color() {}
bool operator==(const Color& other);
}; };
class RGB : public Color { class RGB : public Color {
@ -127,7 +129,7 @@ public:
// check for magic number // check for magic number
std::string entity; std::string entity;
ppm_image_file >> entity; ppm_image_file >> entity;
if (entity != "P6") { if (entity != m_MAGIC_NUMBER) {
throw std::runtime_error("Does not have a magic number"); throw std::runtime_error("Does not have a magic number");
} }
@ -178,7 +180,7 @@ public:
// write to the file on the disk and close it // write to the file on the disk and close it
// magic number // magic number
ppm_image_file << "P6"; ppm_image_file << m_MAGIC_NUMBER;
// newline // newline
ppm_image_file << "\n"; ppm_image_file << "\n";

Loading…
Cancel
Save