removed folder structure

This commit is contained in:
Lauchmelder 2022-01-26 16:58:32 +01:00
parent ffb486b0b9
commit ab40eeb4e2
6 changed files with 430 additions and 6 deletions

42
imageviewer.cpp Normal file
View file

@ -0,0 +1,42 @@
/**
* Displays a given PGM image in the console using ASCII characters
*/
#include <iostream>
#include "bild.hpp"
int main(int argc, char** argv)
{
// If there are no additional arguments print usage info
if(argc < 2)
{
std::cout << "Usage: imageviewer <pgm file>" << std::endl;
return 0;
}
// Load file
std::ifstream file(argv[1]);
if(!file.good())
{
std::cerr << "Failed to open file" << std::endl;
return -1;
}
// Create image
Bild image;
try
{
file >> image;
}
catch(const std::runtime_error& err)
{
std::cerr << err.what() << std::endl;
file.close();
return -1;
}
file.close();
// Print image
std::cout << image << std::endl;
return 0;
}