1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#include <string>
using std::string;
// Type for color images
struct RGBt {
RGBt() : r(0), g(0), b(0) {}
RGBt(float r1, float g1, float b1) : r(r1), g(g1), b(b1) {}
RGBt(float a) : r(a), g(a), b(a) {}
float r;
float g;
float b;
};
// Load a scalar image
// returns true if the image is read successfully, false otherwise.
//
// Arguments:
// filename: image file, can be *.png, *.jpg etc. (any format supported by Qt)
// image: image array (memory will be allocated in this function)
// w: image width
// h: image height
bool loadImage(const string &filename, float *&image, int &w, int &h);
// Load a color image
// returns true if the image is read successfully, false otherwise.
//
// Arguments:
// filename: image file, can be *.png, *.jpg etc. (any format supported by Qt)
// image: image array (memory will be allocated in this function)
// w: image width
// h: image height
bool loadImage(const string &filename, RGBt *&image, int &w, int &h);
// Save a scalar image
// returns true if the image is saved successfully, false otherwise
//
// Arguments:
// image: image array
// w: image width
// h: image height
// filename: image file
bool saveImage(const float *image, int w, int h, const string &filename);
// Save a scalar image
// returns true if the image is saved successfully, false otherwise
//
// Arguments:
// image: image array
// w: image width
// h: image height
// filename: image file
bool saveImage(const RGBt *image, int w, int h, const string &filename);
|