Back to index

extremetuxracer  0.5beta
Public Member Functions | Static Public Member Functions | Public Attributes
pp::Image Class Reference

#include <image.h>

Inheritance diagram for pp::Image:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 Image (int width=0, int height=0, int depth=3)
 ~Image (void)
bool writeToFile (const char *fileName) const

Static Public Member Functions

static ImagereadFile (const char *fileName)

Public Attributes

unsigned short width
unsigned short height
unsigned char depth
unsigned char * data

Detailed Description

Definition at line 24 of file image.h.


Constructor & Destructor Documentation

pp::Image::Image ( int  width = 0,
int  height = 0,
int  depth = 3 
)

Definition at line 31 of file image.cpp.

{
       if(width>0 && height>0 && depth>0 && depth <4){ 
              this->width=width;
              this->height=height;
              this->depth=depth;
              this->data=new unsigned char[width*height*depth];
              return;
       }else{
              this->width=0;
              this->height=0;
              this->depth=0;
              this->data=0;
              return;
       }
}
pp::Image::~Image ( void  )

Definition at line 48 of file image.cpp.

{
       if(data!=0) delete data;    
}

Member Function Documentation

Image * pp::Image::readFile ( const char *  fileName) [static]

Definition at line 54 of file image.cpp.

{
       int len = strlen(fileName);
       
       // PNG Image?
       if(!strcmp(fileName+len-3,"png")){
              Image* image=new ReaderPNG(fileName);
              
              // check if the image contains valid data
              if(image->data!=NULL){
                     return image;        
              } else {
                     delete image;
                     return NULL;
              }
       }else{
              // try it as rgb (should we check for this first?)
              Image* image=new ReaderRGB(fileName);
              return image;        
       }
}

Here is the caller graph for this function:

bool pp::Image::writeToFile ( const char *  fileName) const

Definition at line 77 of file image.cpp.

{
       WriterPPM writer(fileName,*this);
       
       return true;
}

Here is the caller graph for this function:


Member Data Documentation

unsigned char* pp::Image::data

Definition at line 32 of file image.h.

unsigned char pp::Image::depth

Definition at line 31 of file image.h.

unsigned short pp::Image::height

Definition at line 30 of file image.h.

unsigned short pp::Image::width

Definition at line 30 of file image.h.


The documentation for this class was generated from the following files: