basic/geometry/IGS/IGS_ImageByte1.cpp

Go to the documentation of this file.
00001 #include <assert.h>
00002 #include "IGS_ImageByte1.h" 
00003 
00004 //=============================================================================
00005 // constructor
00006 //
00007 // Description: constructs the image
00008 //=============================================================================
00009 IGS_ImageByte1::IGS_ImageByte1():
00010         pixels( NULL )
00011 {
00012         this->SetType( GL_BYTE );
00013 }
00014 
00015 //=============================================================================
00016 // constructor
00017 //
00018 // Description: constructs the image
00019 //=============================================================================
00020 IGS_ImageByte1::~IGS_ImageByte1()
00021 {
00022         delete[] pixels;
00023         pixels = NULL;
00024 }
00025 
00026 //=============================================================================
00027 // GetPixelFloat1
00028 //
00029 // Description: returns a float value for this image
00030 //=============================================================================
00031 const void* const IGS_ImageByte1::GetBuffer() const
00032 {
00033         return this->pixels;
00034 }
00035 
00036 //=============================================================================
00037 // GetPixelFloat1
00038 //
00039 // Description: returns a float value for this image
00040 //=============================================================================
00041 void*& IGS_ImageByte1::GetBuffer()
00042 {
00043         return reinterpret_cast< void*& >( this->pixels );
00044 }
00045 
00046 //=============================================================================
00047 // GetPixelFloat1
00048 //
00049 // Description: returns a float value for this image
00050 //=============================================================================
00051 float IGS_ImageByte1::GetPixelFloat1( const int x, const int y ) const
00052 {
00053         char pixel = this->GetPixelNative( x, y );
00054         return pixel / 255.0f;
00055 }
00056 
00057 //=============================================================================
00058 // GetPixelNative
00059 //
00060 // Description: returns a float value for this image
00061 //=============================================================================
00062 char IGS_ImageByte1::GetPixelNative( const int x, const int y ) const
00063 {
00064         int index = this->ComputeIndex( x, y );
00065         return this->pixels[ index ];
00066 }
00067 
00068 //=============================================================================
00069 // Initialize
00070 //
00071 // Description: initializes the memory array of pixels
00072 //=============================================================================
00073 void IGS_ImageByte1::Initialize()
00074 {
00075         int sizeOfData = IGS_Image::SizeOfType( this->type );
00076         if( pixels != NULL )
00077         {
00078                 delete[] pixels;
00079         }
00080         pixels = new char[ this->sizeX * this->sizeY * sizeOfData ];
00081 }
00082 
00083 //=============================================================================
00084 // PutPixelFloat1
00085 //
00086 // Description: puts a floating point value into the image (1 channel )
00087 //=============================================================================
00088 void IGS_ImageByte1::PutPixelFloat1( const int x, const int y, const float value )
00089 {
00090         assert( false );
00091 }

Generated on Sat Apr 1 21:30:32 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO