PhotoPNG.cpp (1236B)
1 // File : PhotoPNG.cpp 2 // Date : Wed Apr 27 22:46:32 2016 3 // Author : Fabian Wermelinger 4 // Description: PNG Photos implementation 5 // Copyright 2016 ETH Zurich. All Rights Reserved. 6 #include "PhotoPNG.h" 7 8 void PNG_HSV::make_new(const string name, const int width, const int height) 9 { 10 m_fname = name; 11 resize(width, height); 12 } 13 14 void PNG_HSV::resize(const int width, const int height) 15 { 16 if (m_open) 17 { 18 m_png->close(); 19 _dispose(); 20 } 21 m_png = new pngwriter(width, height, m_background, (m_fname+this->suffix()).c_str()); 22 23 m_width = width; 24 m_height = height; 25 m_open = true; 26 } 27 28 void PNG_HSV::write() 29 { 30 if (m_open) 31 { 32 m_png->settext(m_title.c_str(), m_author.c_str(), m_description.c_str(), m_software.c_str()); 33 m_png->write_png(); 34 m_png->close(); 35 _dispose(); 36 m_open = false; 37 } 38 } 39 40 void PNG_HSV::set_pixel(const double phi, const int x, const int y) 41 { 42 if (m_open) 43 { 44 const double hue = 2./3. * (1.0 - phi); 45 m_png->plotHSV(x+1, y+1, hue, m_saturation, m_value); 46 } 47 } 48 49 void PNG_MONO::set_pixel(const double phi, const int x, const int y) 50 { 51 if (m_open) 52 m_png->plot(x+1, y+1, phi, phi, phi); 53 }