summaryrefslogtreecommitdiff
path: root/src/Image/Image_PixelInterpolation.cxx
blob: 1562212312f0c8b0be426259339ad76f9fd4bd76 (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
#include <Image_PixelInterpolation.ixx>

Image_PixelInterpolation::Image_PixelInterpolation() {}

Standard_Boolean Image_PixelInterpolation::DoInterpolate( 
	const Handle(Image_Image)& aImage,
	const Standard_Real X, const Standard_Real Y,
	const Standard_Integer LowX,
	const Standard_Integer LowY,
	const Standard_Integer UpX,
	const Standard_Integer UpY,
	Aspect_Pixel& aPixel ) const

{ Standard_Integer NX ; 
  Standard_Integer NY ; 

  if ( X < 0. ) NX = Standard_Integer(X-0.5) ;
  else		NX = Standard_Integer(X+0.5) ;

  if ( Y < 0. ) NY = Standard_Integer(Y-0.5) ;
  else          NY = Standard_Integer(Y+0.5) ;

  if ( NX < LowX || NX > UpX ||
       NY < LowY || NY > UpY ) {
	return Standard_False ;
  }
  else {
	aImage->Pixel( NX, NY, aPixel );
	return Standard_True ;
  }
}

Standard_Boolean Image_PixelInterpolation::Interpolate( 
	const Handle(Image_Image)& aImage,
	const Standard_Real FX, const Standard_Real FY,
	const Standard_Integer LowX,
	const Standard_Integer LowY,
	const Standard_Integer UpX,
	const Standard_Integer UpY,
	Aspect_Pixel& aPixel ) const

{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }

Standard_Boolean Image_PixelInterpolation::Interpolate( 
	const Handle(Image_DColorImage)& aImage,
	const Standard_Real FX, const Standard_Real FY,
	const Standard_Integer LowX,
	const Standard_Integer LowY,
	const Standard_Integer UpX,
	const Standard_Integer UpY,
	Aspect_ColorPixel& aPixel ) const

{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }

Standard_Boolean Image_PixelInterpolation::Interpolate( 
	const Handle(Image_DIndexedImage)& aImage,
	const Standard_Real FX, const Standard_Real FY,
	const Standard_Integer LowX,
	const Standard_Integer LowY,
	const Standard_Integer UpX,
	const Standard_Integer UpY,
	Aspect_IndexPixel& aPixel ) const

{ return DoInterpolate( aImage, FX, FY, LowX, LowY, UpX, UpY, aPixel ) ; }