diff options
author | Benji Dial <benji@benjidial.net> | 2024-05-18 21:53:38 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-05-18 21:53:38 -0400 |
commit | b1a912a8a6ff472a49b2e0a09cfd433adfc2cb24 (patch) | |
tree | 5009d4415ba13e4baa37f3d0271852528130fd3b /libraries/daguerre/ppm.cpp | |
parent | a8a80d326de9550b2a25b1255a2093ab43219ede (diff) | |
download | hilbert-os-b1a912a8a6ff472a49b2e0a09cfd433adfc2cb24.tar.gz |
reorganization, cross compiler
Diffstat (limited to 'libraries/daguerre/ppm.cpp')
-rw-r--r-- | libraries/daguerre/ppm.cpp | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/libraries/daguerre/ppm.cpp b/libraries/daguerre/ppm.cpp deleted file mode 100644 index e909503..0000000 --- a/libraries/daguerre/ppm.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include <daguerre/image.hpp> -#include <cctype> - -namespace daguerre { - - static unsigned read_int(std::FILE *from) { - unsigned out = 0; - int ch; - do - ch = std::fgetc(from); - while (std::isspace(ch)); - while (true) { - if (ch == EOF) - return out; - if (ch < '0' || ch > '9') { - std::ungetc(ch, from); - return out; - } - out = out * 10 + (ch - '0'); - ch = std::fgetc(from); - } - } - - bool try_load_ppm(std::FILE *from, image<color24> &into) { - - if (std::fgetc(from) != 'P' || std::fgetc(from) != '6' || - std::fgetc(from) != '\n') - return false; - - unsigned width = read_int(from); - unsigned height = read_int(from); - unsigned max = read_int(from); - std::fgetc(from);//newline - - if (max != 255) - return false; - - into = image<color24>(width, height); - color24 *buffer = into.get_buffer(); - - for (unsigned y = 0; y < height; ++y) - for (unsigned x = 0; x < width; ++x) { - buffer[y * width + x].r = std::fgetc(from); - buffer[y * width + x].g = std::fgetc(from); - buffer[y * width + x].b = std::fgetc(from); - } - - return true; - - } - -} |