AutoStereogramDemo.AutoStereogramBuilder.AdjustNearest C# (CSharp) Method

AdjustNearest() private method

update coordinate of nearest point, which visible through given projection on the screen
private AdjustNearest ( int xLeftProj, int xRightProj, int yProj ) : void
xLeftProj int
xRightProj int
yProj int
return void
        private void AdjustNearest(int xLeftProj, int xRightProj, int yProj)
        {
            if (yProj < 0 || yProj >= YResolution)
                return;

            if (xLeftProj >= 0 && xLeftProj < XResolutionInternal)
            {
                if (nearestLeft[xLeftProj, yProj] == null)
                    nearestLeft[xLeftProj, yProj] = xRightProj;
                else
                    nearestLeft[xLeftProj, yProj] = Math.Min(nearestLeft[xLeftProj, yProj].Value, xRightProj);
            }

            if (xRightProj >= 0 && xRightProj < XResolutionInternal)
            {
                if (nearestRight[xRightProj, yProj] == null)
                    nearestRight[xRightProj, yProj] = xLeftProj;
                else
                    nearestRight[xRightProj, yProj] = Math.Max(nearestRight[xRightProj, yProj].Value, xLeftProj);
            }
        }