Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Image.cpp

Go to the documentation of this file.
00001 // Image.cpp: Implementierung der Klasse Image.
00002 //
00004 #include <stddef.h>
00005 #include "Image.h"
00006 
00007 using namespace ns_vu1112116;
00008 
00010 // Konstruktion/Destruktion
00012 
00013 Image::Image()
00014 {
00015   spix = NULL;
00016   init(0,0);
00017 }
00018 
00019 Image::~Image()
00020 {
00021         if(spix) delete [] spix;
00022 }
00023 
00024 bool Image::init(int sizx, int sizy)
00025 {
00026   maxx=sizx;
00027   maxy=sizy;
00028   if(spix) delete [] spix;
00029   if(sizx && sizy)
00030     {
00031       spix = new byte[maxx*maxy*3];
00032       if(!spix) return false;
00033     } else spix = NULL;
00034   return true;
00035 }
00036 
00037 bool Image::set_xy(int x, int y, const vuColourRGBa& col)
00038 {
00039         if(x<0 || y<0 || x>=maxx || y>=maxy) return false;
00040         vuColourRGBa rgb(col);
00041         rgb.clampTo01();
00042         byte *pix = &spix[(x+maxx*y)*3];
00043         pix[0] = byte(255.0f * rgb[0]);
00044         pix[1] = byte(255.0f * rgb[1]);
00045         pix[2] = byte(255.0f * rgb[2]);
00046         return true;
00047 }
00048 
00049 bool Image::get_xy(int x, int y, vuColourRGBa &col)
00050 {
00051         if(x<0 || y<0 || x>=maxx || y>=maxy) return false;
00052         col = spix[x+maxx*y];
00053         return true;
00054 }
00055 
00056 const byte* Image::get_rgb() const
00057 {
00058   return spix;
00059 }
00060 
00061 void Image::get_extents(int &sizx, int &sizy)
00062 {
00063         sizx=maxx;
00064         sizy=maxy;
00065 }

Generated on Wed Dec 15 21:20:29 2004 for vuVolume by  doxygen 1.3.9.1