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

drawRect_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 <drawRect_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ---------------------------------------------------------------------- */
00043 drawRect_Filter::drawRect_Filter(uint32_t x1,
00044                                  uint32_t y1, 
00045                                  uint32_t x2,
00046                                  uint32_t y2, 
00047                                  uint32_t fill,
00048                                  int channel) :
00049     phFilter("drawRect_Filter")
00050 
00051 {
00052     this->m_format = phImageRGB24;
00053 
00054     set(x1,y1,x2,y2,fill,channel);
00055 }
00056 
00057 /* ---------------------------------------------------------------------- */
00058 drawRect_Filter::~drawRect_Filter()
00059 {
00060 }
00061 
00062 /* ------------------------------------------------------------------------ */
00063 phFilter *drawRect_Filter::cloneFilter()
00064 {
00065     phFUNCTION("drawRect_Filter::cloneFilter")
00066     int locked = 0;
00067     drawRect_Filter *draw = new drawRect_Filter();
00068 
00069     phTHIS_LOOSE_LOCK(locked);
00070     
00071     rc = draw->set(this->m_x1,
00072                    this->m_y1, 
00073                    this->m_x2,
00074                    this->m_y2, 
00075                    this->m_fill,
00076                    this->m_channel);
00077     phPRINT_RC(rc,NULL,"draw->set failed");
00078 
00079     phTHIS_LOOSE_UNLOCK(locked);
00080 
00081     return (phFilter *)draw;
00082 }
00083 
00084 /* ---------------------------------------------------------------------- */
00085 int drawRect_Filter::set(uint32_t x1,
00086                          uint32_t y1, 
00087                          uint32_t x2,
00088                          uint32_t y2, 
00089                          uint32_t fill,
00090                          int channel )
00091 {
00092     phFUNCTION("drawRect_Filter::set")
00093     int locked = 0;
00094 
00095     phTHIS_LOOSE_LOCK(locked);
00096     
00097     this->m_x1 = x1;
00098     this->m_y1 = y1;
00099     this->m_x2 = x2;
00100     this->m_y2 = y2;
00101     this->m_fill = fill;
00102     this->m_channel = channel;
00103 
00104     phTHIS_LOOSE_UNLOCK(locked);
00105 
00106     return phSUCCESS;
00107 }
00108 
00109 /* ---------------------------------------------------------------------- */
00110 int drawRect_Filter::filter()
00111 {
00112     phFUNCTION("drawRect_Filter::filter")
00113 
00114     /* Declare function variables */
00115     uint32_t w = 0;
00116     uint32_t h = 0;
00117     uint32_t row = 0;
00118    
00119     /* Begin filter */
00120     
00121     for(h = this->m_y1; h <= this->m_y2; h++ ) 
00122     {
00123         row = h * width;
00124         for(w = this->m_x1; w <= this->m_x2; w++) 
00125         {
00126             if ((this->m_fill == 1) || 
00127                 ((h == this->m_x1) || (h == this->m_x2) ||
00128                  (w == this->m_y1) || (w == this->m_y2)))
00129             {
00130                 if (this->m_channel == phCHANNEL_ALL)
00131                 {
00132                     phMemset((void *)&((Image)[(row + w) * depth]),
00133                            255,
00134                            depth);
00135                 }
00136                 else
00137                 {
00138                     (Image)[(row + w) * depth + this->m_channel] = 255;
00139                 }
00140             }
00141         }
00142     }
00143     
00144     return phSUCCESS;
00145 /*
00146 error:
00147     return phFAIL;
00148 */
00149 }
00150 
00151 




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:09 2007 for phission by  doxygen 1.4.4