#include <Texture.hpp>
Public Member Functions | |
| Texture () | |
| ~Texture () | |
Static Public Member Functions | |
| static void | export_ppm (const std::string &filename, const unsigned int &size_1, const int &size_2, const std::vector< float > &red_channel, const std::vector< float > &green_channel, const std::vector< float > &blue_channel) |
| Export ppm texture. | |
Definition at line 8 of file Texture.hpp.
| Texture::Texture | ( | ) |
| Texture::~Texture | ( | ) |
| void Texture::export_ppm | ( | const std::string & | filename, | |
| const unsigned int & | size_1, | |||
| const int & | size_2, | |||
| const std::vector< float > & | red_channel, | |||
| const std::vector< float > & | green_channel, | |||
| const std::vector< float > & | blue_channel | |||
| ) | [static] |
Export ppm texture.
| filename,: | the name of the picture | |
| size_1,: | size in x direction | |
| size_2,: | size in y direction | |
| r_channel,: | red component (must be of size size_1*size_2) | |
| g_channel,: | green component (must be of size size_1*size_2) | |
| b_channel,: | blue component (must be of size size_1*size_2) |
Values must be between [0,255]. Otherwise clamped.
Definition at line 6 of file Texture.cpp.
Referenced by main().
00007 { 00008 std::ofstream stream(filename.c_str(),std::ofstream::out); 00009 if(!stream.good()) 00010 throw std::string("Error in Texture::export_ppm("+filename+"...) : cannot open file \n"); 00011 00012 //magic number 00013 stream<<"P3 \n"; 00014 //size 00015 stream<<size_2<<" "<<size_1<<" \n"; 00016 //color number 00017 stream<<"255"<<std::endl; 00018 00019 for(int k2=0;k2<size_2;++k2) 00020 { 00021 for(unsigned int k1=0;k1<size_1;++k1) 00022 { 00023 int r=std::min(std::max(static_cast<int>(red_channel [k1+size_1*k2]),0),255); 00024 int g=std::min(std::max(static_cast<int>(green_channel[k1+size_1*k2]),0),255); 00025 int b=std::min(std::max(static_cast<int>(blue_channel [k1+size_1*k2]),0),255); 00026 00027 stream<<r<<" "<<g<<" "<<b<<std::endl; 00028 } 00029 } 00030 stream.close(); 00031 00032 }

1.6.1