0023912: TDataStd_ExtStringArray::Value() returns a copy of TCollection_ExtendedStrin...
[occt.git] / src / Image / Image_GPixelField.lxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
3 //
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
8 //
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
11 //
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
18
19 #include <Standard_DimensionMismatch.hxx>
20 #include <Standard_OutOfRange.hxx>
21 #include Item_hxx
22
23 #include <stdio.h>
24
25 # ifdef WNT
26 #  include <InterfaceGraphic_wntio.hxx>
27 # endif  // WNT
28
29 //static char *ErrorMessag, LocalMessag[255];
30 static char LocalMessag[255];
31
32 inline Standard_Integer Image_GPixelField::Width()  const { return myWidth; }
33 inline Standard_Integer Image_GPixelField::Height() const { return myHeight; }
34 inline Standard_Integer Image_GPixelField::UpperX() const { return myWidth-1; }
35 inline Standard_Integer Image_GPixelField::UpperY() const { return myHeight-1; }
36
37 //=======================================================================
38 //function : SetValue
39 //purpose  : 
40 //=======================================================================
41
42 inline void Image_GPixelField::SetValue ( const Standard_Integer X,
43                                    const Standard_Integer Y,
44                                    const Item& Value )
45 {
46    if (X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1)) {
47         sprintf(LocalMessag,
48                 "Index out of range in PixelField::SetValue(%d,%d)",X,Y);
49         Standard_OutOfRange::Raise (LocalMessag);
50    }
51
52   ((Item *)myData)[(Y)*(myWidth)+X] = Value ;
53 }
54
55 //=======================================================================
56 //function : Value
57 //purpose  : 
58 //=======================================================================
59
60 inline const Item& Image_GPixelField::Value(const Standard_Integer X,
61                                      const Standard_Integer Y) const
62 {
63    if (X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1)) {
64         sprintf(LocalMessag,
65                 "Index out of range in PixelField::Value(%d,%d)",X,Y);
66         Standard_OutOfRange::Raise (LocalMessag);
67    }
68
69   return ((Item *)myData)[(Y)*(myWidth)+X] ;
70
71
72 //=======================================================================
73 //function : ChangeValue
74 //purpose  : 
75 //=======================================================================
76
77 inline Item& Image_GPixelField::ChangeValue(const Standard_Integer X,
78                                      const Standard_Integer Y)
79 {
80    if ((X < 0 || X > (myWidth  -1) || Y < 0 || Y > (myHeight -1))) {
81         sprintf(LocalMessag,
82                 "Index out of range in PixelField::ChangeValue(%d,%d)",X,Y);
83         Standard_OutOfRange::Raise (LocalMessag);
84    }
85
86   return ((Item *)myData)[(Y)*(myWidth)+X] ;
87 }
88