diff --git a/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs b/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs
index 3f479ac..51d4efe 100644
--- a/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs
+++ b/MarketData/MarketDataLib/CNNProcessing/ImageHelper.cs
@@ -408,26 +408,30 @@ namespace MarketData.CNNProcessing
}
}
+ ///
+ /// Fills the rectangle with the specified color
+ ///
+ ///
public void Fill(SKColor color)
{
SKRectI rect = new SKRectI(0, 0, Width, Height); // x, y, width, height
bitmap.Erase(color, rect);
- }
-
- ///
- /// DrawPoint - With translation
- ///
- ///
- ///
- public void DrawPoint(SKColor color,SKPoint drawPoint)
- {
- Validate();
- using SKCanvas canvas = new SKCanvas(bitmap);
- canvas.Clear();
- SKPoint txPoint = pointMapping.MapPoint(drawPoint);
- canvas.DrawPoint(drawPoint, color);
}
+ ///
+ /// DrawPoint - With translation
+ ///
+ ///
+ ///
+ public void DrawPoint(SKColor color, SKPoint drawPoint)
+ {
+ Validate();
+ using SKCanvas canvas = new SKCanvas(bitmap);
+ canvas.Clear();
+ SKPoint txPoint = pointMapping.MapPoint(drawPoint);
+ canvas.DrawPoint(drawPoint, color);
+ }
+
///
/// DrawPoint - with given strokeWidth and translation
///
diff --git a/MarketData/MarketDataLib/CNNProcessing/PointMapping.cs b/MarketData/MarketDataLib/CNNProcessing/PointMapping.cs
index 41bfa9e..8774caa 100755
--- a/MarketData/MarketDataLib/CNNProcessing/PointMapping.cs
+++ b/MarketData/MarketDataLib/CNNProcessing/PointMapping.cs
@@ -33,13 +33,23 @@ namespace MarketData.CNNProcessing
XScalingFactor = pointMapping.XScalingFactor;
YScalingFactor = pointMapping.YScalingFactor;
}
-
-// MapPoint will both scale the given point and translate the given point from an upper left origin system to a bottom left origin system
+
+ ///
+ /// MapPoint will both scale the given point and translate the given point from an upper left origin system to a bottom left origin system
+ /// Because of the scaling factor (XScalingFactor and YScalingFactor) it is possible for the resulting X,Y values to be rounded out of range.
+ /// To remedy this we perform a boundary check of the X,Y points against the extents and set them to those extents if they are out of range.
+ ///
+ ///
+ ///
public SKPoint MapPoint(SKPoint sourcePoint)
{
- SKPoint mappedPoint = new SKPoint((int)((sourcePoint.X - XDataExtentMin) * XScalingFactor), (int)(Height - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor)));
+ SKPoint mappedPoint = new SKPoint((int)((sourcePoint.X - XDataExtentMin) * XScalingFactor), (int)((Height - 1) - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor)));
mappedPoint.X += (int)XMargin; // offset by the xMargin
mappedPoint.Y -= (int)YMargin; // offset by the yMargin
+ if (mappedPoint.X > XDataExtent) mappedPoint.X = (int)XDataExtent; // constrain X to XDataExtent
+ if (mappedPoint.Y > YDataExtent) mappedPoint.Y = (int)YDataExtent; // constrain Y to YDataExtent
+ if (mappedPoint.X < XDataExtentMin) mappedPoint.X = (int)XDataExtentMin; // constrain X to XDataExtentMin
+ if (mappedPoint.Y < YDataExtentMin) mappedPoint.Y = (int)YDataExtentMin; // constrain Y to YDataExtentMin
return mappedPoint;
}
// TranslatePoint will only translate the given point from an upper left origin system to a bottom left origin system
@@ -48,7 +58,8 @@ namespace MarketData.CNNProcessing
SKPoint mappedPoint=new SKPoint((int)sourcePoint.X,(int)(Height-sourcePoint.Y-1));
return mappedPoint;
}
- public double Width{get;private set;}
+
+ public double Width { get; private set; }
public double Height{get;private set;}
public double XDataExtent{get;private set;}
public double XDataExtentMin{get;private set;}