Main Page | Class Hierarchy | Class List | File List | Class Members

macros.h

00001 /* 00002 * This file is part of libCP 00003 * FILE: macros.h 00004 * AUTHOR: Harald Studer <hs@lexip.ch> 00005 * Mathias Herzog <mathu@gmx.ch> 00006 * 00007 * 00008 * Copyright (c) 2004, The libCP project 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your opinion) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; see the file COPYING. If not, write to 00022 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00023 * Boston, MA 02111-1307, USA. 00024 */ 00025 #ifndef _MACROS_H_ 00026 #define _MACROS_H_ 00027 00028 #include "misc.h" 00029 00030 namespace LIBCP{ 00031 00032 #define NOT_BINARY_IMAGE -1 00033 #define NOT_GRAY_IMAGE -2 00034 #define NOT_COLOR_IMAGE -3 00035 #define NOT_COLOR24_IMAGE -4 00036 #define NOT_COLOR32_IMAGAE -5 00037 #define BINARY_IMAGE -6 00038 #define DIFFERENT_IMAGE_WIDTH -7 00039 #define DIFFERENT_IMAGE_HEIGHT -8 00040 #define DIFFERENT_IMAGE_TYPE -9 00041 #define NOT_POWER_OF_2 -10 00042 #define ODD_PARAMETER -11 00043 #define EVEN_PARAMETER -12 00044 00045 00049 #define ASSERT_BINARY_IMAGE(img) if( img->type() != BaseImage::BINARY ) \ 00050 return NOT_BINARY_IMAGE 00051 00055 #define ASSERT_COLOR_IMAGE(img) \ 00056 if( img->type() != BaseImage::COLOR32 && img->type() != BaseImage::COLOR24 ) \ 00057 return NOT_COLOR_IMAGE 00058 00062 #define ASSERT_COLOR32_IMAGE(img) if( img->type() != BaseImage::COLOR32 ) \ 00063 return NOT_COLOR32_IMAGE 00064 00068 #define ASSERT_COLOR24_IMAGE(img) if( img->type() != BaseImage::COLOR24 ) \ 00069 return NOT_COLOR24_IMAGE 00070 00074 #define ASSERT_GRAY_IMAGE(img) if( img->type() != BaseImage::GRAY ) \ 00075 return NOT_GRAY_IMAGE 00076 00080 #define ASSERT_NOT_BINARY_IMAGE(img) if( img->type() == BaseImage::BINARY ) \ 00081 return BINARY_IMAGE 00082 00086 #define ASSERT_WIDTH(src,dst) if( src->width() != dst->width() ) \ 00087 return DIFFERENT_IMAGE_WIDTH 00088 00092 #define ASSERT_HEIGHT(src,dst) if( src->height() != dst->height() ) \ 00093 return DIFFERENT_IMAGE_HEIGHT 00094 00098 #define ASSERT_TYPE(src,dst) if( src->type() != dst->type() ) \ 00099 return DIFFERENT_IMAGE_TYPE 00100 00104 #define ASSERT_EVEN(number) if ( number % 2 != 0 ) \ 00105 return ODD_PARAMETER 00106 00110 #define ASSERT_ODD(number) if ( number % 2 == 0 ) \ 00111 return EVEN_PARAMETER 00112 00116 #define ASSERT_POWER_OF_2(img) int m = 0; if( !Misc::isPowerOfTwo( img->width(), \ 00117 m ) || !Misc::isPowerOfTwo( img->height(), m ) \ 00118 ) return NOT_POWER_OF_2 00119 00123 #define IS_COLOR_IMAGE(img) img->type() == Image::COLOR24 || \ 00124 img->type() == Image::COLOR32 00125 00129 #define IS_COLOR32_IMAGE(img) img->type() == Image::COLOR32 00130 00134 #define IS_COLOR24_IMAGE(img) img->type() == Image::COLOR24 00135 00139 #define IS_GRAY_IMAGE(img) img->type() == Image::GRAY 00140 00144 #define IS_BINARY_IMAGE(img) img->type() == Image::BINARY 00145 00150 #define IMAGE_LOOP_START(img,i,j) for( i = 0; i < img->width(); i++ ){ \ 00151 for( j = 0; j < img->height(); j++ ){ 00152 00156 #define IMAGE_LOOP_END }} 00157 00167 #define WINDOW_LOOP_START(img,w,i,j,x,y) int w2 = w / 2; \ 00168 for( int i = -w2; i <= w2; i++ ){ \ 00169 for( int j = -w2; j <= w2; j++ ){ \ 00170 if( !img->isValidPixel(x+i,y+j) ) continue; 00171 00175 #define WINDOW_LOOP_END }} 00176 00177 } //end of namespace LIBCP 00178 00179 #endif //_MACROS_H_

Generated on Wed May 26 16:43:53 2004 for libcp by doxygen 1.3.7