|
@ -3,8 +3,6 @@ |
|
|
#include <cmath> |
|
|
#include <cmath> |
|
|
#include <cstdlib> |
|
|
#include <cstdlib> |
|
|
#include <cassert> |
|
|
#include <cassert> |
|
|
//#include <cstdint>
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
#include "pngwriter/pngwriter.h" |
|
|
#include "pngwriter/pngwriter.h" |
|
|
|
|
|
|
|
@ -101,8 +99,8 @@ void Canvas::plot(double x, double y, unsigned int c, double intensity) { |
|
|
I/O functions |
|
|
I/O functions |
|
|
*/ |
|
|
*/ |
|
|
void Canvas::output() { |
|
|
void Canvas::output() { |
|
|
cout << "Canvas: " << endl; |
|
|
std::cout << "Canvas: " << std::endl; |
|
|
cout << "Dimensions: " << width << " x " << height << " x " << num_colors << endl; |
|
|
std::cout << "Dimensions: " << width << " x " << height << " x " << num_colors << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Canvas::output_file(const char * filename){ |
|
|
void Canvas::output_file(const char * filename){ |
|
@ -134,7 +132,7 @@ void Canvas::output_file(const char * filename){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if ( n <= 10 ) { |
|
|
if ( n <= 10 ) { |
|
|
cout << "not enough data" << endl; |
|
|
std::cout << "not enough data" << std::endl; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -185,13 +183,13 @@ void Canvas::output_file(const char * filename){ |
|
|
delete max_int; |
|
|
delete max_int; |
|
|
delete power; |
|
|
delete power; |
|
|
|
|
|
|
|
|
cout << "ready for writing file i suppose: " << filename << endl; |
|
|
std::cout << "ready for writing file i suppose: " << filename << std::endl; |
|
|
|
|
|
|
|
|
ofstream file(filename); |
|
|
std::ofstream file(filename); |
|
|
if ( !file ) { |
|
|
if ( !file ) { |
|
|
cout << "jij hebt pech, geen png voor jou" << endl; |
|
|
std::cout << "jij hebt pech, geen png voor jou" << std::endl; |
|
|
} |
|
|
} |
|
|
cout << filename << endl; |
|
|
std::cout << filename << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pngFile->close(); |
|
|
pngFile->close(); |
|
@ -212,7 +210,7 @@ void Canvas::output_file(){ |
|
|
|
|
|
|
|
|
void Canvas::output_raw(const char * filename){ |
|
|
void Canvas::output_raw(const char * filename){ |
|
|
|
|
|
|
|
|
ofstream outfile (filename, ofstream::binary); |
|
|
std::ofstream outfile (filename, std::ofstream::binary); |
|
|
|
|
|
|
|
|
outfile.write(reinterpret_cast<char*>(int_array), sizeof(unsigned int)*width*height*num_colors); |
|
|
outfile.write(reinterpret_cast<char*>(int_array), sizeof(unsigned int)*width*height*num_colors); |
|
|
|
|
|
|
|
@ -230,18 +228,18 @@ void Canvas::output_raw(){ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Canvas::input_raw(const char * filename){ |
|
|
void Canvas::input_raw(const char * filename){ |
|
|
ifstream infile(filename, ifstream::binary); |
|
|
std::ifstream infile(filename, std::ifstream::binary); |
|
|
|
|
|
|
|
|
if ( ! infile ) { |
|
|
if ( ! infile ) { |
|
|
cout << "poep" << endl; |
|
|
std::cout << "poep" << std::endl; |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
infile.seekg (0, ios::end); |
|
|
infile.seekg (0, std::ios::end); |
|
|
int length = infile.tellg(); |
|
|
int length = infile.tellg(); |
|
|
infile.seekg (0, ios::beg); |
|
|
infile.seekg (0, std::ios::beg); |
|
|
|
|
|
|
|
|
cout << "length: " << length << " =? " << static_cast<int>(width*height*num_colors*sizeof(unsigned int)) << endl; |
|
|
std::cout << "length: " << length << " =? " << static_cast<int>(width*height*num_colors*sizeof(unsigned int)) << std::endl; |
|
|
|
|
|
|
|
|
infile.read (reinterpret_cast<char*>(int_array), sizeof (unsigned int)*width*height*num_colors); |
|
|
infile.read (reinterpret_cast<char*>(int_array), sizeof (unsigned int)*width*height*num_colors); |
|
|
} |
|
|
} |
|
|