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

swapPlanes_Filter.cpp

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009  ---------------------------------------------------------------------------
00010     <Add other copyrights here> 
00011  ---------------------------------------------------------------------------
00012 
00013     This file is part of Phission.
00014 
00015     Phission is free software; you can redistribute it and/or modify
00016     it under the terms of the GNU Lesser General Public License as published by
00017     the Free Software Foundation; either version 2 of the License, or
00018     (at your option) any later version.
00019 
00020     Phission is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public License
00026     along with Phission; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029  ---------------------------------------------------------------------------*/
00030 #ifdef HAVE_CONFIG_H
00031     #include <phissionconfig.h>
00032 #endif
00033 
00034 #include <phStandard.h>
00035 
00036 #include <swapPlanes_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ---------------------------------------------------------------------- */
00043 swapPlanes_Filter::swapPlanes_Filter(uint32_t d1, uint32_t d2) :
00044     phFilter("swapPlanes_Filter")
00045 
00046 {
00047     this->m_format = phImagePackedFormatMask;
00048     this->set(d1,d2);
00049 }
00050 
00051 /* ---------------------------------------------------------------------- */
00052 swapPlanes_Filter::~swapPlanes_Filter()
00053 {
00054 }
00055 
00056 /* ------------------------------------------------------------------------ */
00057 phFilter *swapPlanes_Filter::cloneFilter()
00058 {
00059     phFUNCTION("swapPlanes_Filter::cloneFilter")
00060     int locked = 0;
00061     swapPlanes_Filter *swapfilter = new swapPlanes_Filter();
00062 
00063     phTHIS_LOOSE_LOCK(locked)
00064     
00065     swapfilter->set(this->m_d1,this->m_d2);
00066     
00067     phTHIS_LOOSE_UNLOCK(locked)
00068     
00069     return (phFilter *)swapfilter;
00070 }
00071 
00072 /* ---------------------------------------------------------------------- */
00073 int swapPlanes_Filter::set(uint32_t d1, uint32_t d2)
00074 {
00075     phFUNCTION("swapPlanes_Filter::set")
00076     int locked = 0;
00077      
00078     phTHIS_LOOSE_LOCK(locked);
00079     
00080     this->m_d1 = d1;
00081     this->m_d2 = d2;
00082     
00083     phTHIS_LOOSE_UNLOCK(locked);
00084     
00085     return phSUCCESS;
00086 }
00087 
00088 /* ---------------------------------------------------------------------- */
00089 int swapPlanes_Filter::filter()
00090 {
00091     phFUNCTION("swapPlanes_Filter::filter")
00092 
00093     const uint32_t  limit   = width * height;
00094     uint32_t        pixel   = 0;
00095     uint8_t        *imgptr  = NULL;
00096     uint8_t         temp    = 0;
00097     
00098     for ( pixel = 0; pixel < limit; pixel++) 
00099     {
00100         temp                = imgptr[this->m_d1];
00101         imgptr[this->m_d1]  = imgptr[this->m_d2];
00102         imgptr[this->m_d2]  = temp;
00103         imgptr += depth;
00104     }
00105     
00106     return phSUCCESS;
00107 }
00108 
00109 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:11 2007 for phission by  doxygen 1.4.4