00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023
00024
00025
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