Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

ImageGrey.h

00001 /*
00002 OpenMorpho Library - Mathematical Morphology (Image processing) Library
00003 Copyright (C) 2000  Laurent Najman
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 
00019 You can contact the author at
00020         mailto:laurent@najman.org
00021 and download the latest version at
00022         http://www.laurentnajman.org
00023 */
00024 
00025 // ImageGrey.h: interface for the CImageGrey class.
00026 //
00028 
00029 #if !defined(AFX_IMAGEGREY_H__3E9B40A5_8698_11D4_B181_E5930507415E__INCLUDED_)
00030 #define AFX_IMAGEGREY_H__3E9B40A5_8698_11D4_B181_E5930507415E__INCLUDED_
00031 
00032 #define OpenMorphoVER 1
00033 #define OpenMorphoOptVER 0
00034 
00035 #ifndef SWIG // Remove whatever is not needed by SWIG
00036 
00037 #if _MSC_VER >= 1000
00038 #pragma once
00039 #endif // _MSC_VER >= 1000
00040 
00041 #ifdef _WINDOWS
00042 #include <windows.h>
00043 #endif
00044 
00045 #include "PixelTypes.h"
00046 #include "Error.h"
00047 
00048 #endif // SWIG
00049 
00070 class CImageGrey : public CError
00071 {
00072         LPPIXEL pBitmap;        
00073         int Width, Height;      
00074         int MaxIndex;           
00075         int LineLength;         
00076         int Top, Left;          
00077 
00078         static int nb_images; 
00079 
00080 public:
00082         CImageGrey();
00083 #ifndef SWIG
00084 
00085         CImageGrey(int sx, int sy);
00087         CImageGrey(CImageGrey *in);
00088 #endif
00089 
00090         virtual ~CImageGrey();
00091 
00093         inline int NbImagesGet(void) const { return nb_images; };
00095         inline int HeightGet(void) const { return Height; };
00097         inline int WidthGet(void) const { return Width; };
00099         inline int TopGet(void) const { return Top; };
00101         inline int LeftGet(void) const { return Left; };
00103         inline int LineLengthGet(void) const { return LineLength; };
00105         inline LPPIXEL BitmapGet(void) const { return pBitmap; };
00107         inline int MaxIndexGet(void) const { return MaxIndex; };
00109         inline LPPIXEL BeginGet(void) const { return pBitmap + 1 + LineLength; };
00111         inline PIXEL PixelGet(int x, int y) const { return *(pBitmap +1 + LineLength + x + y * LineLength); };
00113         inline void PixelSet(int x, int y, PIXEL value) const {  *(pBitmap +1 + LineLength + x + y * LineLength) = value; };
00114 
00116         void FrameSet(PIXEL val);
00118                 void Set(PIXEL val);
00119 
00121         inline LPPIXEL dir6c_0(LPPIXEL p, short parity) const {
00122                 return ( p + 1 );
00123         };
00125         inline LPPIXEL dir6c_1(LPPIXEL p, short parity) const {
00126                 return ( p - LineLength + parity );
00127         };
00129         inline LPPIXEL dir6c_2(LPPIXEL p, short parity) const {
00130                 return ( p - LineLength + parity - 1 );
00131         };
00133         inline LPPIXEL dir6c_3(LPPIXEL p, short parity) const {
00134                 return ( p - 1 );
00135         };
00137         inline LPPIXEL dir6c_4(LPPIXEL p, short parity) const {
00138                 return ( p + LineLength + parity - 1 );
00139         };
00141         inline LPPIXEL dir6c_5(LPPIXEL p, short parity) const {
00142                 return ( p + LineLength + parity );
00143         };
00144 
00146         inline LPPIXEL dir4c_0(LPPIXEL p) const {
00147                 return ( p + 1 );
00148         };
00150         inline LPPIXEL dir4c_1(LPPIXEL p) const {
00151                 return ( p - LineLength );
00152         };
00154         inline LPPIXEL dir4c_2(LPPIXEL p) const {
00155                 return ( p - 1 );
00156         };
00158         inline LPPIXEL dir4c_3(LPPIXEL p) const {
00159                 return ( p + LineLength );
00160         };
00161 
00163         inline LPPIXEL dir8c_0(LPPIXEL p) const {
00164                 return ( p + 1 );
00165         };
00167         inline LPPIXEL dir8c_1(LPPIXEL p) const {
00168                 return ( p - LineLength + 1);
00169         };
00171         inline LPPIXEL dir8c_2(LPPIXEL p) const {
00172                 return ( p - LineLength );
00173         };
00175         inline LPPIXEL dir8c_3(LPPIXEL p) const {
00176                 return ( p - LineLength - 1);
00177         };
00179         inline LPPIXEL dir8c_4(LPPIXEL p) const {
00180                 return ( p - 1 );
00181         };
00183         inline LPPIXEL dir8c_5(LPPIXEL p) const {
00184                 return ( p + LineLength - 1);
00185         };
00187         inline LPPIXEL dir8c_6(LPPIXEL p) const {
00188                 return ( p + LineLength );
00189         };
00191         inline LPPIXEL dir8c_7(LPPIXEL p) const {
00192                 return ( p + LineLength + 1 );
00193         };
00195                 inline bool isInImage(LPPIXEL p) const {
00196                         int x, y, z;
00197                         z = (p-pBitmap -Left-Top*LineLength);
00198                         y = z / LineLength;
00199                         x = z % LineLength;
00200                         if ((x<0) || (x>Width) || (y<0) || (y>Height))
00201                                 return false;
00202                 
00203                         return true;
00204                 };
00205 };
00206 
00207 #endif // !defined(AFX_IMAGEGREY_H__3E9B40A5_8698_11D4_B181_E5930507415E__INCLUDED_)
00208 
00209 

Generated at Sun May 12 19:04:22 2002 for OpenMorpho by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000