Skip to content

Instantly share code, notes, and snippets.

@topin89
Last active November 6, 2019 09:01
Show Gist options
  • Save topin89/aa1c378ac9f6a6b920195716f08bc1db to your computer and use it in GitHub Desktop.
Save topin89/aa1c378ac9f6a6b920195716f08bc1db to your computer and use it in GitHub Desktop.

Revisions

  1. topin89 revised this gist Nov 6, 2019. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions writepxm.cpp
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,13 @@
    #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::ofstream file{filename, std::ios::binary};
    file << "P6\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
    }
    @@ -13,7 +17,7 @@ void writepgm(char const * const image_buffer,
    int const width,
    int const height,
    std::string const filename){
    std::ofstream file{filename};
    std::ofstream file{filename, std::ios::binary};
    file << "P5\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
    }
  2. topin89 revised this gist Nov 6, 2019. No changes.
  3. topin89 revised this gist Nov 3, 2019. 1 changed file with 10 additions and 10 deletions.
    20 changes: 10 additions & 10 deletions writepxm.cpp
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    void writeppm(unsigned char const * const image_buffer,
    unsigned int const image_size,
    unsigned int const width,
    unsigned int const height,
    unsigned std::string const filename){
    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};
    file << "P6\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
    }

    void writepgm(unsigned char const * const image_buffer,
    unsigned int const image_size,
    unsigned int const width,
    unsigned int const height,
    unsigned std::string const filename){
    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};
    file << "P5\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
  4. topin89 created this gist Sep 19, 2019.
    19 changes: 19 additions & 0 deletions writepxm.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    void writeppm(unsigned char const * const image_buffer,
    unsigned int const image_size,
    unsigned int const width,
    unsigned int const height,
    unsigned std::string const filename){
    std::ofstream file{filename};
    file << "P6\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
    }

    void writepgm(unsigned char const * const image_buffer,
    unsigned int const image_size,
    unsigned int const width,
    unsigned int const height,
    unsigned std::string const filename){
    std::ofstream file{filename};
    file << "P5\n" << width << '\n' << height << "\n255\n";
    file.write(image_buffer, image_size);
    }