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

invert_Filter.cpp

Go to the documentation of this file.
00001 #include <invert_Filter.h>
00002 
00003 /* ---------------------------------------------------------------------- */
00004 /* (int channel, int value) */
00005 /* ---------------------------------------------------------------------- */
00006 invert_Filter::invert_Filter() :
00007     phFilter("invert_Filter")
00008 
00009 {
00010     this->m_format = phImageValidFormatMask;
00011     this->m_pixelbuf = NULL;
00012     this->m_pixelbuf_size = 0;
00013 }
00014 
00015 /* ---------------------------------------------------------------------- */
00016 invert_Filter::~invert_Filter()
00017 {
00018 }
00019 
00020 /* ------------------------------------------------------------------------ */
00021 phFilter *invert_Filter::cloneFilter()
00022 {
00023     return (phFilter *)new invert_Filter();
00024 }
00025 
00026 /* ---------------------------------------------------------------------- */
00027 int invert_Filter::filter()
00028 {
00029     phFUNCTION("invert_Filter::filter")
00030      
00031     uint8_t *ptr = NULL;
00032     uint8_t *ptr2 = NULL;
00033     uint32_t pixel_half = (width * height) / 2;
00034     /* defined before being called:
00035      *  width
00036      *  height
00037      *  depth
00038      *  Image
00039      */
00040     
00041     phDALLOC(this->m_pixelbuf,
00042              this->m_pixelbuf_size,
00043              depth,
00044              uint8_t);
00045 
00046     /* Begin Filter */
00047     ptr = Image;
00048     ptr2 = Image + ((width * height * depth ) - (depth));
00049     for (int32_t pixel = 0; pixel < pixel_half; pixel++ , ptr += depth, ptr2 -= depth)
00050     {
00051         phMemcpy(this->m_pixelbuf,ptr2,depth * sizeof(uint8_t));
00052         phMemcpy(ptr2,ptr,depth * sizeof(uint8_t));
00053         phMemcpy(ptr,this->m_pixelbuf,depth * sizeof(uint8_t));
00054     }
00055     
00056     /* End Filter */
00057     
00058     /* make sure to free up any space here, not including Image */
00059     
00060     return phSUCCESS;
00061     
00062 /* Comment this back in if you use any macros that jump to here, ie phCHECK_RC,
00063  * or phCHECK_PTR */
00064 
00065 error:
00066     /* make sure to free up any space here, not including Image */
00067     
00068     return phFAIL;
00069     
00070 }
00071 




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