Ejemplo n.º 1
0
		/// <summary>
		/// image remap. Not affecting Alpha.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="pXMap">Device memory pointer to 2D image array of X coordinate values to be used when sampling source image. </param>
		/// <param name="pYMap">Device memory pointer to 2D image array of Y coordinate values to be used when sampling source image. </param>
		/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
		public void RemapA(NPPImage_8uC4 dst, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation)
		{
			NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.Remap.nppiRemap_8u_AC4R(_devPtr, _sizeRoi, _pitch, srcRect, pXMap.DevicePointerRoi, pXMap.Pitch, pYMap.DevicePointerRoi, pYMap.Pitch, dst.DevicePointerRoi, dst.Pitch, dst.SizeRoi, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRemap_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Determines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
		/// </summary>
		/// <param name="rect"></param>
		/// <returns></returns>
		public bool Contains(NppiRect rect)
		{
			return Contains(rect.Location) && Contains(rect.Location + rect.Size);
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Returns a third Rectangle structure that represents the intersection of two other Rectangle structures.If there is no intersection, an empty Rectangle is returned. 
		/// </summary>
		/// <param name="rectA"></param>
		/// <param name="rectB"></param>
		/// <returns></returns>
		public static NppiRect Intersect(NppiRect rectA, NppiRect rectB)
		{
			int iX = rectA.Left;
			if (iX < rectB.Left)
			{
				iX = rectB.Left;
			}

			int iY = rectA.Top;
			if (iY < rectB.Top)
			{
				iY = rectB.Top;
			}

			int iX2 = rectA.Right;
			if (iX2 > rectB.Right)
			{
				iX2 = rectB.Right;
			}

			int iY2 = rectA.Bottom;
			if (iY2 > rectB.Bottom)
			{
				iY2 = rectB.Bottom;
			}

			int iWidth = iX2 - iX + 1;
			int iHeight = iY2 - iY + 1;
			if (iWidth <= 0 || iHeight <= 0)
			{
				iX = 0;
				iY = 0;
				iWidth = 0;
				iHeight = 0;
			}
			return new NppiRect(iX, iY, iWidth, iHeight);
		}
Ejemplo n.º 4
0
		/// <summary>
		/// per element Divide
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Divide(int src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src / value.x, src / value.y, src / value.width, src / value.height);
			return ret;
		}
Ejemplo n.º 5
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Divide(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width / value.width, src.height / value.height);
			return ret;
		}
Ejemplo n.º 6
0
		/// <summary>
		/// per element Multiply
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Multiply(int src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src * value.x, src * value.y, src * value.width, src * value.height);
			return ret;
		}
Ejemplo n.º 7
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Multiply(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width * value.width, src.height * value.height);
			return ret;
		}
Ejemplo n.º 8
0
		/// <summary>
		/// Perspective transform of an image. Not affecting Alpha channel.<para/>
		/// This function performs perspective warping of a the specified
		/// quadrangle in the source image to the specified quadrangle in the
		/// destination image. The function nppiWarpPerspectiveQuad uses the same
		/// formulas for pixel mapping as in nppiWarpPerspective function. The
		/// transform coefficients are computed internally.
		/// The transformed part of the source image is resampled using the specified
		/// interpolation method and written to the destination ROI.<para/>
		/// NPPI specific recommendation: <para/>
		/// The function operates using 2 types of kernels: fast and accurate. The fast
		/// method is about 4 times faster than its accurate variant,
		/// but doesn't perform memory access checks and requires the destination ROI
		/// to be 64 bytes aligned. Hence any destination ROI is 
		/// chunked into 3 vertical stripes: the first and the third are processed by
		/// accurate kernels and the central one is processed by the fast one.
		/// In order to get the maximum available speed of execution, the projection of
		/// destination ROI onto image addresses must be 64 bytes aligned. This is
		/// always true if the values <para/>
		/// <code>(int)((void *)(pDst + dstRoi.x))</code> and <para/>
		/// <code>(int)((void *)(pDst + dstRoi.x + dstRoi.width))</code> <para/>
		/// are multiples of 64. Another rule of thumb is to specify destination ROI in
		/// such way that left and right sides of the projected image are separated from
		/// the ROI by at least 63 bytes from each side. However, this requires the
		/// whole ROI to be part of allocated memory. In case when the conditions above
		/// are not satisfied, the function may decrease in speed slightly and will
		/// return NPP_MISALIGNED_DST_ROI_WARNING warning.
		/// </summary>
		/// <param name="srcQuad">Source quadrangle [4,2]</param>
		/// <param name="dest">Destination image</param>
		/// <param name="destQuad">Destination quadrangle [4,2]</param>
		/// <param name="eInterpolation">Interpolation mode: can be <see cref="InterpolationMode.NearestNeighbor"/>, <see cref="InterpolationMode.Linear"/> or <see cref="InterpolationMode.Cubic"/></param>
		public void WarpPerspectiveQuadA(double[,] srcQuad, NPPImage_32sC4 dest, double[,] destQuad, InterpolationMode eInterpolation)
		{
			NppiRect rectIn = new NppiRect(_pointRoi, _sizeRoi);
			NppiRect rectOut = new NppiRect(dest.PointRoi, dest.SizeRoi);
			status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_32s_AC4R(_devPtr, _sizeOriginal, _pitch, rectIn, srcQuad, dest.DevicePointer, dest.Pitch, rectOut, destQuad, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_32s_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Ejemplo n.º 9
0
		/// <summary>
		/// Perspective transform of an image.<para/>
		/// This function performs perspective warping of a the specified
		/// quadrangle in the source image to the specified quadrangle in the
		/// destination image. The function nppiWarpPerspectiveQuad uses the same
		/// formulas for pixel mapping as in nppiWarpPerspective function. The
		/// transform coefficients are computed internally.
		/// The transformed part of the source image is resampled using the specified
		/// interpolation method and written to the destination ROI.<para/>
		/// NPPI specific recommendation: <para/>
		/// The function operates using 2 types of kernels: fast and accurate. The fast
		/// method is about 4 times faster than its accurate variant,
		/// but doesn't perform memory access checks and requires the destination ROI
		/// to be 64 bytes aligned. Hence any destination ROI is 
		/// chunked into 3 vertical stripes: the first and the third are processed by
		/// accurate kernels and the central one is processed by the fast one.
		/// In order to get the maximum available speed of execution, the projection of
		/// destination ROI onto image addresses must be 64 bytes aligned. This is
		/// always true if the values <para/>
		/// <code>(int)((void *)(pDst + dstRoi.x))</code> and <para/>
		/// <code>(int)((void *)(pDst + dstRoi.x + dstRoi.width))</code> <para/>
		/// are multiples of 64. Another rule of thumb is to specify destination ROI in
		/// such way that left and right sides of the projected image are separated from
		/// the ROI by at least 63 bytes from each side. However, this requires the
		/// whole ROI to be part of allocated memory. In case when the conditions above
		/// are not satisfied, the function may decrease in speed slightly and will
		/// return NPP_MISALIGNED_DST_ROI_WARNING warning.
		/// </summary>
		/// <param name="src0">Source image (Channel 0)</param>
		/// <param name="src1">Source image (Channel 1)</param>
		/// <param name="src2">Source image (Channel 2)</param>
		/// <param name="srcQuad">Source quadrangle [4,2]</param>
		/// <param name="dest0">Destination image (Channel 0)</param>
		/// <param name="dest1">Destination image (Channel 1)</param>
		/// <param name="dest2">Destination image (Channel 2)</param>
		/// <param name="destQuad">Destination quadrangle [4,2]</param>
		/// <param name="eInterpolation">Interpolation mode: can be <see cref="InterpolationMode.NearestNeighbor"/>, <see cref="InterpolationMode.Linear"/> or <see cref="InterpolationMode.Cubic"/></param>
		public static void WarpPerspectiveQuad(NPPImage_32sC1 src0, NPPImage_32sC1 src1, NPPImage_32sC1 src2, double[,] srcQuad, NPPImage_32sC1 dest0, NPPImage_32sC1 dest1, NPPImage_32sC1 dest2, double[,] destQuad, InterpolationMode eInterpolation)
		{
			NppiRect rectIn = new NppiRect(src0.PointRoi, src0.SizeRoi);
			NppiRect rectOut = new NppiRect(dest0.PointRoi, dest0.SizeRoi);

			CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer };
			CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointer, dest1.DevicePointer, dest2.DevicePointer };

			NppStatus status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiWarpPerspectiveQuad_32s_P4R(src, src0.Size, src0.Pitch, rectIn, srcQuad, dst, dest0.Pitch, rectOut, destQuad, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiWarpPerspectiveQuad_32s_P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Ejemplo n.º 10
0
		/// <summary>
		/// Calculates affine transform projection of given source rectangular ROI
		/// </summary>
		/// <param name="coeffs">Affine transform coefficients [2,3]</param>
		/// <returns>Destination quadrangle [4,2]</returns>
		public double[,] GetAffineQuad(double[,] coeffs)
		{
			double[,] quad = new double[4, 2];
			NppiRect rect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.AffinTransforms.nppiGetAffineQuad(rect, quad, coeffs);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGetAffineQuad", status));
			NPPException.CheckNppStatus(status, this);
			return quad;
		}
Ejemplo n.º 11
0
		/// <summary>
		/// Calculates bounding box of the affine transform projection of the given source rectangular ROI
		/// </summary>
		/// <param name="coeffs">Perspective transform coefficients [3,3]</param>
		/// <returns>Destination quadrangle [2,2]</returns>
		public double[,] GetPerspectiveBound(double[,] coeffs)
		{
			double[,] bound = new double[2, 2];
			NppiRect rect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.PerspectiveTransforms.nppiGetPerspectiveBound(rect, bound, coeffs);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiGetPerspectiveBound", status));
			NPPException.CheckNppStatus(status, this);
			return bound;
		}
Ejemplo n.º 12
0
		/// <summary>
		/// planar image remap.
		/// </summary>
		/// <param name="src0">Source image (Channel 0)</param>
		/// <param name="src1">Source image (Channel 1)</param>
		/// <param name="src2">Source image (Channel 2)</param>
		/// <param name="src3">Source image (Channel 3)</param>
		/// <param name="dest0">Destination image (Channel 0)</param>
		/// <param name="dest1">Destination image (Channel 1)</param>
		/// <param name="dest2">Destination image (Channel 2)</param>
		/// <param name="dest3">Destination image (Channel 3)</param>
		/// <param name="pXMap">Device memory pointer to 2D image array of X coordinate values to be used when sampling source image. </param>
		/// <param name="pYMap">Device memory pointer to 2D image array of Y coordinate values to be used when sampling source image. </param>
		/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
		public static void Remap(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3, NPPImage_32fC1 pXMap, NPPImage_32fC1 pYMap, InterpolationMode eInterpolation)
		{
			CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer, src3.DevicePointer };
			CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointerRoi, dest1.DevicePointerRoi, dest2.DevicePointerRoi, dest3.DevicePointerRoi };
			NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi);
			NppStatus status = NPPNativeMethods.NPPi.Remap.nppiRemap_8u_P4R(src, src0.SizeRoi, src0.Pitch, srcRect, pXMap.DevicePointerRoi, pXMap.Pitch, pYMap.DevicePointerRoi, pYMap.Pitch, dst, dest0.Pitch, dest0.SizeRoi, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiRemap_8u_P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Ejemplo n.º 13
0
		/// <summary>
		/// planar image resize.
		/// </summary>
		/// <param name="src0">Source image (Channel 0)</param>
		/// <param name="src1">Source image (Channel 1)</param>
		/// <param name="src2">Source image (Channel 2)</param>
		/// <param name="src3">Source image (Channel 3)</param>
		/// <param name="dest0">Destination image (Channel 0)</param>
		/// <param name="dest1">Destination image (Channel 1)</param>
		/// <param name="dest2">Destination image (Channel 2)</param>
		/// <param name="dest3">Destination image (Channel 3)</param>
		/// <param name="nXFactor">Factor by which x dimension is changed. </param>
		/// <param name="nYFactor">Factor by which y dimension is changed. </param>
		/// <param name="nXShift">Source pixel shift in x-direction.</param>
		/// <param name="nYShift">Source pixel shift in y-direction.</param>
		/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
		public static void ResizeSqrPixel(NPPImage_8uC1 src0, NPPImage_8uC1 src1, NPPImage_8uC1 src2, NPPImage_8uC1 src3, NPPImage_8uC1 dest0, NPPImage_8uC1 dest1, NPPImage_8uC1 dest2, NPPImage_8uC1 dest3, double nXFactor, double nYFactor, double nXShift, double nYShift, InterpolationMode eInterpolation)
		{
			CUdeviceptr[] src = new CUdeviceptr[] { src0.DevicePointer, src1.DevicePointer, src2.DevicePointer, src3.DevicePointer };
			CUdeviceptr[] dst = new CUdeviceptr[] { dest0.DevicePointer, dest1.DevicePointer, dest2.DevicePointer, dest3.DevicePointer };
			NppiRect srcRect = new NppiRect(src0.PointRoi, src0.SizeRoi);
			NppiRect dstRect = new NppiRect(dest0.PointRoi, dest0.SizeRoi);
			NppStatus status = NPPNativeMethods.NPPi.ResizeSqrPixel.nppiResizeSqrPixel_8u_P4R(src, src0.SizeRoi, src0.Pitch, srcRect, dst, dest0.Pitch, dstRect, nXFactor, nYFactor, nXShift, nYShift, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResizeSqrPixel_8u_P4R", status));
			NPPException.CheckNppStatus(status, null);
		}
Ejemplo n.º 14
0
		/// <summary>
		/// image conversion. Not affecting Alpha.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="nMin">specifies the minimum saturation value to which every output value will be clamped.</param>
		/// <param name="nMax">specifies the maximum saturation value to which every output value will be clamped.</param>
		public void ScaleA(NPPImage_32fC4 dst, float nMin, float nMax)
		{
			NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.Scale.nppiScale_8u32f_AC4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, nMin, nMax);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiScale_8u32f_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Ejemplo n.º 15
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Subtract(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width - value.width, src.height - value.height);
			return ret;
		}
Ejemplo n.º 16
0
		/// <summary>
		/// image conversion.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="hint">algorithm performance or accuracy selector, currently ignored</param>
		public void Scale(NPPImage_8uC4 dst, NppHintAlgorithm hint)
		{
			NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
			status = NPPNativeMethods.NPPi.Scale.nppiScale_32s8u_C4R(_devPtrRoi, _pitch, dst.DevicePointerRoi, dst.Pitch, _sizeRoi, hint);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiScale_32s8u_C4R", status));
			NPPException.CheckNppStatus(status, this);
		}
Ejemplo n.º 17
0
		/// <summary>
		/// per element Multiply
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Multiply(NppiRect src, int value)
		{
			NppiRect ret = new NppiRect(src.x * value, src.y * value, src.width * value, src.height * value);
			return ret;
		}
Ejemplo n.º 18
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Add(NppiRect src, int value)
		{
			NppiRect ret = new NppiRect(src.x + value, src.y + value, src.width + value, src.height + value);
			return ret;
		}
Ejemplo n.º 19
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Multiply(NppiPoint src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src.x * value.x, src.y * value.y, value.width, value.height);
			return ret;
		}
Ejemplo n.º 20
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Add(NppiPoint src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src.x + value.x, src.y + value.y, value.width, value.height);
			return ret;
		}
Ejemplo n.º 21
0
		/// <summary>
		/// per element Divide
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Divide(NppiRect src, int value)
		{
			NppiRect ret = new NppiRect(src.x / value, src.y / value, src.width / value, src.height / value);
			return ret;
		}
Ejemplo n.º 22
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Add(NppiSize src, NppiRect value)
		{
			NppiRect ret = new NppiRect(value.x, value.y, src.width + value.width, src.height + value.height);
			return ret;
		}
Ejemplo n.º 23
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Divide(NppiPoint src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src.x / value.x, src.y / value.y, value.width, value.height);
			return ret;
		}
Ejemplo n.º 24
0
		/// <summary>
		/// per element Substract
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Subtract(NppiRect src, int value)
		{
			NppiRect ret = new NppiRect(src.x - value, src.y - value, src.width - value, src.height - value);
			return ret;
		}
Ejemplo n.º 25
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public bool Equals(NppiRect value)
		{
			bool ret = true;
			ret &= this.x == value.x;
			ret &= this.width == value.width;
			ret &= this.y == value.y;
			ret &= this.height == value.height;
			return ret;
		}
Ejemplo n.º 26
0
		/// <summary>
		/// per element Substract
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Subtract(int src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src - value.x, src - value.y, src - value.width, src - value.height);
			return ret;
		}
Ejemplo n.º 27
0
		/// <summary>
		/// Replaces this Rectangle with the intersection of itself and the specified Rectangle.
		/// </summary>
		/// <param name="rect"></param>
		public void Intersect(NppiRect rect)
		{
			int iX = Left;
			if (iX < rect.Left)
			{
				iX = rect.Left;
			}

			int iY = Top;
			if (iY < rect.Top)
			{
				iY = rect.Top;
			}

			int iX2 = Right;
			if (iX2 > rect.Right)
			{
				iX2 = rect.Right;
			}

			int iY2 = Bottom;
			if (iY2 > rect.Bottom)
			{
				iY2 = rect.Bottom;
			}

			int iWidth = iX2 - iX + 1;
			int iHeight = iY2 - iY + 1;
			if (iWidth <= 0 || iHeight <= 0)
			{
				iX = 0;
				iY = 0;
				iWidth = 0;
				iHeight = 0;
			}
			x = iX;
			y = iY;
			width = iWidth;
			height = iHeight;
		}
Ejemplo n.º 28
0
		/// <summary>
		/// per element Add
		/// </summary>
		/// <param name="src"></param>
		/// <param name="value"></param>
		/// <returns></returns>
		public static NppiRect Subtract(NppiPoint src, NppiRect value)
		{
			NppiRect ret = new NppiRect(src.x - value.x, src.y - value.y, value.width, value.height);
			return ret;
		}
Ejemplo n.º 29
0
		/// <summary>
		/// Determines if this rectangle intersects with rect.
		/// </summary>
		/// <param name="rect"></param>
		/// <returns></returns>
		public bool IntersectsWith(NppiRect rect)
		{

			int iX = Left;
			if (iX < rect.Left)
			{
				iX = rect.Left;
			}

			int iY = Top;
			if (iY < rect.Top)
			{
				iY = rect.Top;
			}

			int iX2 = Right;
			if (iX2 > rect.Right)
			{
				iX2 = rect.Right;
			}

			int iY2 = Bottom;
			if (iY2 > rect.Bottom)
			{
				iY2 = rect.Bottom;
			}

			int iWidth = iX2 - iX + 1;
			int iHeight = iY2 - iY + 1;
			if (iWidth <= 0 || iHeight <= 0)
			{
				return false;
			}
			return true;
		}
Ejemplo n.º 30
0
		/// <summary>
		/// image resize. Not affecting Alpha.
		/// </summary>
		/// <param name="dst">Destination-Image</param>
		/// <param name="nXFactor">Factor by which x dimension is changed. </param>
		/// <param name="nYFactor">Factor by which y dimension is changed. </param>
		/// <param name="nXShift">Source pixel shift in x-direction.</param>
		/// <param name="nYShift">Source pixel shift in y-direction.</param>
		/// <param name="eInterpolation">The type of eInterpolation to perform resampling.</param>
		public void ResizeSqrPixelA(NPPImage_8uC4 dst, double nXFactor, double nYFactor, double nXShift, double nYShift, InterpolationMode eInterpolation)
		{
			NppiRect srcRect = new NppiRect(_pointRoi, _sizeRoi);
			NppiRect dstRect = new NppiRect(dst.PointRoi, dst.SizeRoi);
			status = NPPNativeMethods.NPPi.ResizeSqrPixel.nppiResizeSqrPixel_8u_AC4R(_devPtr, _sizeRoi, _pitch, srcRect, dst.DevicePointer, dst.Pitch, dstRect, nXFactor, nYFactor, nXShift, nYShift, eInterpolation);
			Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "nppiResizeSqrPixel_8u_AC4R", status));
			NPPException.CheckNppStatus(status, this);
		}