Fix ImageHelper not rendering images due to issue in PointMapping.
Some checks failed
Build .NET Project / build (push) Has been cancelled
Some checks failed
Build .NET Project / build (push) Has been cancelled
This commit is contained in:
@@ -29,7 +29,9 @@ namespace MarketData.CNNProcessing
|
||||
XMargin = pointMapping.XMargin;
|
||||
YMargin = pointMapping.YMargin;
|
||||
XDataExtent = pointMapping.XDataExtent;
|
||||
XDataExtentMin = pointMapping.XDataExtentMin;
|
||||
YDataExtent = pointMapping.YDataExtent;
|
||||
YDataExtentMin = pointMapping.YDataExtentMin;
|
||||
XScalingFactor = pointMapping.XScalingFactor;
|
||||
YScalingFactor = pointMapping.YScalingFactor;
|
||||
}
|
||||
@@ -43,15 +45,22 @@ namespace MarketData.CNNProcessing
|
||||
/// <returns></returns>
|
||||
public SKPoint MapPoint(SKPoint sourcePoint)
|
||||
{
|
||||
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;
|
||||
}
|
||||
SKPoint mappedPoint = new SKPoint(
|
||||
(float)((sourcePoint.X - XDataExtentMin) * XScalingFactor),
|
||||
(float)((Height - 1) - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor))
|
||||
);
|
||||
|
||||
mappedPoint.X += (float)XMargin;
|
||||
mappedPoint.Y -= (float)YMargin;
|
||||
|
||||
// Clamp to image bounds
|
||||
if (mappedPoint.X > Width - 1) mappedPoint.X = (float)(Width - 1);
|
||||
if (mappedPoint.Y > Height - 1) mappedPoint.Y = (float)(Height - 1);
|
||||
if (mappedPoint.X < 0) mappedPoint.X = 0;
|
||||
if (mappedPoint.Y < 0) mappedPoint.Y = 0;
|
||||
|
||||
return mappedPoint;
|
||||
}
|
||||
// TranslatePoint will only translate the given point from an upper left origin system to a bottom left origin system
|
||||
public SKPoint TranslatePoint(SKPoint sourcePoint)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user