#ifndef TEXTURE_SPH_H #define TEXTURE_SPH_H #include #include #include "read_image.h" using std::min; using std::max; class texture_image { public: texture_image() {texture = 0; height = width = 0;} long GetColor(double u, double v) const { assert(texture && height > 0 && width > 0); u = max(0.0, min(u, .99999)); v = max(0.0, min(v, .99999)); int x = (int)(u * width); int y = (int)(v * height); return texture[x][y]; } bool LoadImage(const char* file) { return !load_image(file, height, width, texture); } private: int height, width; long ** texture; }; #endif