src/rcrt/textures/Image.h

Go to the documentation of this file.
00001 #ifndef IMAGE_HXX
00002 #define IMAGE_HXX
00003 
00004 #include <iostream>
00005 #include "../RGBAColor.h"
00006 
00007 namespace rcrt
00008 {
00009 
00010 class Image
00011 {
00012     int resX, resY;
00013     RGBAColor* pixel;
00014 
00015 public:
00016     Image(int resX,int resY) : resX(resX),resY(resY)
00017     {
00018         pixel = new RGBAColor[resX*resY];
00019     }
00020 
00021     Image() : resX(0),resY(0)
00022     {
00023         pixel = 0;
00024     }
00025 
00026     ~Image()
00027     { 
00028         if (pixel) delete[] pixel;
00029     }
00030     
00031     RGBAColor* operator[](int y)
00032     { 
00033         return pixel + y * resX; 
00034     }
00035 
00037     int getWidth() const { return resX; }
00038 
00040     int getHeight() const { return resY; }
00041 
00043     RGBAColor& getPixel (int x, int y)
00044     { 
00045         if (x < 0 || y < 0)
00046                 std::cout << "x=" << x << ", y=" << y << std::endl;
00047 
00048         // return pixel
00049         return pixel[y * resX + x]; 
00050     }
00051 
00053     void setPixel (const RGBAColor& p, int x, int y)
00054     { 
00055         // return pixel
00056         pixel[y * resX + x] = p; 
00057     }
00058     
00059     void setPixel (const RGBColor& p, int x, int y)
00060     { 
00061         // return pixel
00062         pixel[y * resX + x] = p; 
00063     }
00064     
00066     void WritePPM(const char *fileName);
00067 
00069     bool ReadPPM(const char *fileName);
00070 
00075     bool ReadPNG(const char* fileName);
00076 
00080     void WritePNG(const char* fileName);
00081 
00086     bool LoadImage(const char* fileName);
00087     
00088     void ToneMapping(float Ldmax);
00089 
00090 };
00091 
00092 }
00093 
00094 #endif

Generated on Thu Jan 31 19:26:20 2008 for RenderingCompetitionRayTracer by  doxygen 1.5.3