or.cpp

00001
00002 /***************************************************************************
00003  *  or.cpp - Implementation for "or'ing" images together
00004  *
00005  *  Created: Fri May 13 14:57:10 2005
00006  *  Copyright  2005-2007  Tim Niemueller [www.niemueller.de]
00007  *
00008  ****************************************************************************/
00009
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version. A runtime exception applies to
00014  *  this software (see LICENSE.GPL_WRE file mentioned below for details).
00015  *
00016  *  This program is distributed in the hope that it will be useful,
00017  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  *  GNU Library General Public License for more details.
00020  *
00021  *  Read the full text in the LICENSE.GPL_WRE file in the doc directory.
00022  */
00023
00024 #include "filters/or.h"
00025
00026 #include <core/exception.h>
00027
00028 #include <cstddef>
00029 #include <ippi.h>
00030 
00031 /** @class FilterOr <filters/or.h>
00032  * Or filter.
00033  * @author Tim Niemueller
00034  */
00035 
00036 /** Constructor. */
00037 FilterOr::FilterOr()
00038   : Filter("FilterOr", 2)
00039 {
00040 }
00041
00042
00043 void
00044 FilterOr::apply()
00045 {
00046   IppiSize size;
00047   size.width = src_roi[0]->width;
00048   size.height = src_roi[0]->height;
00049
00050   IppStatus status;
00051
00052   if ( (dst == NULL) || (dst == src[1]) ) {
00053     // In-place
00054     status = ippiOr_8u_C1IR(src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step),
00055                             src_roi[0]->line_step,
00056                             src[1] + (src_roi[1]->start.y * src_roi[1]->line_step) + (src_roi[1]->start.x * src_roi[1]->pixel_step),
00057                             src_roi[1]->line_step,
00058                             size);
00059
00060   } else {
00061     status = ippiOr_8u_C1R(src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step),
00062                            src_roi[0]->line_step,
00063                            src[1] + (src_roi[1]->start.y * src_roi[1]->line_step) + (src_roi[1]->start.x * src_roi[1]->pixel_step),
00064                            src_roi[1]->line_step,
00065                            dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step),
00066                            dst_roi->line_step,
00067                            size);
00068   }
00069
00070   if ( status != ippStsNoErr ) {
00071     throw fawkes::Exception("Or filter failed with %i\n", status);
00072   }
00073
00074 }