summaryrefslogtreecommitdiff
path: root/inc/Image_GPixelField.lxx
blob: 60bbeaf5c48dbfa097dbdde15566cd1ac495e42b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <Standard_DimensionMismatch.hxx>
#include <Standard_OutOfRange.hxx>
#include Item_hxx

#include <stdio.h>

# ifdef WNT
#  include <InterfaceGraphic_wntio.hxx>
# endif  // WNT

//static char *ErrorMessag, LocalMessag[255];
static char LocalMessag[255];

inline Standard_Integer Image_GPixelField::Width()  const { return myWidth; }
inline Standard_Integer Image_GPixelField::Height() const { return myHeight; }
inline Standard_Integer Image_GPixelField::UpperX() const { return myWidth-1; }
inline Standard_Integer Image_GPixelField::UpperY() const { return myHeight-1; }

//=======================================================================
//function : SetValue
//purpose  : 
//=======================================================================

inline void Image_GPixelField::SetValue ( const Standard_Integer X,
                                   const Standard_Integer Y,
                                   const Item& Value )
{
   if (X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1)) {
	sprintf(LocalMessag,
		"Index out of range in PixelField::SetValue(%d,%d)",X,Y);
	Standard_OutOfRange::Raise (LocalMessag);
   }

  ((Item *)myData)[(Y)*(myWidth)+X] = Value ;
}

//=======================================================================
//function : Value
//purpose  : 
//=======================================================================

inline const Item& Image_GPixelField::Value(const Standard_Integer X,
                                     const Standard_Integer Y) const
{
   if (X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1)) {
	sprintf(LocalMessag,
		"Index out of range in PixelField::Value(%d,%d)",X,Y);
	Standard_OutOfRange::Raise (LocalMessag);
   }

  return ((Item *)myData)[(Y)*(myWidth)+X] ;
} 

//=======================================================================
//function : ChangeValue
//purpose  : 
//=======================================================================

inline Item& Image_GPixelField::ChangeValue(const Standard_Integer X,
                                     const Standard_Integer Y)
{
   if ((X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1))) {
	sprintf(LocalMessag,
		"Index out of range in PixelField::ChangeValue(%d,%d)",X,Y);
	Standard_OutOfRange::Raise (LocalMessag);
   }

  return ((Item *)myData)[(Y)*(myWidth)+X] ;
}