The Machine Perception Toolbox

[Introduction]- [News]- [Download]- [Screenshots]- [Manual (pdf)]- [Forums]- [API Reference]- [Repository ]

 

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

ffimage.h

Go to the documentation of this file.
00001 /*
00002  *  ffimage.h
00003  *  
00004  *
00005  *  Created by Ian Fasel 2002.
00006  *  Copyright (c) 2003 Machine Perception Laboratory
00007  *  University of California San Diego.
00008  *  Please read the disclaimer and notes about redistribution
00009  *  at the end of this file.
00010  *
00011  *  Authors: Ian Fasel, Bret Fortenberry
00012  *
00013  */
00014 #ifndef _FFIMAGE_H_
00015 #define _FFIMAGE_H_
00016 #include "../common.h"
00017 #include "rimage.h"
00018 #include <iostream>
00019 
00020 template <class T>
00021 class FFImage : public RImage<T> {
00022 public:
00023   // Construct an FFImage from a pixel array
00024   FFImage(T *array_, const int width_, const int height_, const bool flipped)
00025     : RImage<T>(array_, width_, height_), m_flipped(flipped){};
00026    
00027   FFImage(T *array_, const int width_, const int height_)
00028     : RImage<T>(array_, width_, height_)
00029         {
00030 #ifdef WIN32
00031                 m_flipped = true;
00032 #else
00033                 m_flipped = false;
00034 #endif
00035         };
00036    
00037   FFImage<T> (const FFImage<T> &other){
00038                 width = other.width;
00039                 height = other.height;
00040                 numpixels = other.numpixels;
00041                 array = other.array;
00042                 m_flipped = other.m_flipped;
00043                 my_memory = false;
00044   }
00045   
00046   // A copy constructor specific to the RGBTRIPLE case, used to convert from RGB to grayscale
00047   FFImage<T>(const FFImage<RGBTRIPLE>& source, int subs);
00048 
00049   FFImage<T>(const bool flipped = FALSE) : m_flipped(flipped){};
00050   ~FFImage(){;};
00051   
00052   inline T getPixel ( const int x, int y ) const{       
00053         if(m_flipped) y = height-y;
00054         if(x >= 0 && y >= 0 && x < width && y < height)
00055           return array[width * y + x];
00056         else
00057 #ifdef WIN32
00058           return array[0];
00059 #else
00060           return 0;
00061 #endif
00062   };
00063   
00064   inline void setPixel ( const int x, int y, const T value ){
00065         if(m_flipped) y = height-y;
00066         if(x >= 0 && y >= 0 && x < width && y < height)
00067           array[width * y + x] = value;
00068   };
00069 
00070   inline void setSize(const int width_, const int height_, const bool flipped_){
00071         width = width_;
00072         height = height_;
00073         array = new T[width * height];
00074         m_flipped = flipped_;
00075         my_memory = 1;
00076   }
00077 
00078   inline void setSize(const int width_, const int height_){
00079         width = width_;
00080         height = height_;
00081         array = new T[width * height];
00082 #ifdef WIN32
00083                 m_flipped = true;
00084 #else
00085                 m_flipped = false;
00086 #endif
00087         my_memory = 1;
00088   }
00089 
00090   inline bool isFlipped() const {return m_flipped;};
00091 private:
00092         bool m_flipped;
00093 };
00094 
00095 #endif
00096 
00097 /*
00098  * 
00099  * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
00100  * 
00101  *    1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
00102  *    2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
00103  *    3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
00104  * 
00105  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00106  * 
00107  */
00108 

Generated on Mon Nov 8 17:07:33 2004 for MPT by  doxygen 1.3.9.1