Last active
November 6, 2019 09:01
-
-
Save topin89/aa1c378ac9f6a6b920195716f08bc1db to your computer and use it in GitHub Desktop.
Write PGM or PPM images (Portable Graymap and Portable Pixmap)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
#include <iostream> | |
#include <string> | |
void writeppm(char const * const image_buffer, | |
int const image_size, | |
int const width, | |
int const height, | |
std::string const filename){ | |
std::ofstream file{filename, std::ios::binary}; | |
file << "P6\n" << width << '\n' << height << "\n255\n"; | |
file.write(image_buffer, image_size); | |
} | |
void writepgm(char const * const image_buffer, | |
int const image_size, | |
int const width, | |
int const height, | |
std::string const filename){ | |
std::ofstream file{filename, std::ios::binary}; | |
file << "P5\n" << width << '\n' << height << "\n255\n"; | |
file.write(image_buffer, image_size); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment