Fix ImageHelper
This commit is contained in:
@@ -18,7 +18,7 @@ namespace MarketData.CNNProcessing
|
||||
public ImageHelper(ImageHelper imageHelper)
|
||||
{
|
||||
this.bitmap=Copy(imageHelper.bitmap);
|
||||
pointMapping = new PointMapping(Width,Height,Width-1,0,Height-1,0);
|
||||
pointMapping = new PointMapping(imageHelper.pointMapping);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -141,7 +141,7 @@ namespace MarketData.CNNProcessing
|
||||
public void CreateImage(int width, int height)
|
||||
{
|
||||
DisposeAll();
|
||||
this.pointMapping = new PointMapping(width, height, width, 0, height, 0, 0,0);
|
||||
this.pointMapping = new PointMapping(width, height, width-1, 0, height-1, 0, 0,0);
|
||||
bitmap=new SKBitmap(width,height,SKColorType.Rgba8888, SKAlphaType.Premul);
|
||||
Validate();
|
||||
}
|
||||
|
||||
@@ -2,27 +2,44 @@
|
||||
|
||||
namespace MarketData.CNNProcessing
|
||||
{
|
||||
/// <summary>
|
||||
/// This class provides functionality to both scale and map data points from an upper left coordinate system to a lower left coordinate system
|
||||
/// </summary>
|
||||
public class PointMapping
|
||||
{
|
||||
public PointMapping(double width,double height,double xDataExtent,double xDataExtentMin,double yDataExtent,double yDataExtentMin,double xMarginExtent=0.00,double yMarginExtent=0.00)
|
||||
|
||||
public PointMapping(double width, double height, double xDataExtent, double xDataExtentMin, double yDataExtent, double yDataExtentMin, double xMarginExtent = 0.00, double yMarginExtent = 0.00)
|
||||
{
|
||||
Width=width;
|
||||
Height=height;
|
||||
XMargin=xMarginExtent;
|
||||
YMargin=yMarginExtent;
|
||||
XDataExtent=xDataExtent;
|
||||
XDataExtentMin=xDataExtentMin;
|
||||
YDataExtent=yDataExtent;
|
||||
YDataExtentMin=yDataExtentMin;
|
||||
XScalingFactor=(Width-(XMargin*2.00))/(XDataExtent-XDataExtentMin);
|
||||
YScalingFactor=(Height-(YMargin*2.00))/(YDataExtent-YDataExtentMin);
|
||||
Width = width;
|
||||
Height = height;
|
||||
XMargin = xMarginExtent;
|
||||
YMargin = yMarginExtent;
|
||||
XDataExtent = xDataExtent;
|
||||
XDataExtentMin = xDataExtentMin;
|
||||
YDataExtent = yDataExtent;
|
||||
YDataExtentMin = yDataExtentMin;
|
||||
XScalingFactor = (Width - (XMargin * 2.00)) / (XDataExtent - XDataExtentMin);
|
||||
YScalingFactor = (Height - (YMargin * 2.00)) / (YDataExtent - YDataExtentMin);
|
||||
}
|
||||
|
||||
public PointMapping(PointMapping pointMapping)
|
||||
{
|
||||
Width = pointMapping.Width;
|
||||
Height = pointMapping.Height;
|
||||
XMargin = pointMapping.XMargin;
|
||||
YMargin = pointMapping.YMargin;
|
||||
XDataExtent = pointMapping.XDataExtent;
|
||||
YDataExtent = pointMapping.YDataExtent;
|
||||
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
|
||||
public SKPoint MapPoint(SKPoint sourcePoint)
|
||||
{
|
||||
SKPoint mappedPoint=new SKPoint((int)((sourcePoint.X-XDataExtentMin)*XScalingFactor),(int)(Height-((sourcePoint.Y-YDataExtentMin)*YScalingFactor)));
|
||||
mappedPoint.X+=(int)XMargin; // offset by the xMargin
|
||||
mappedPoint.Y-=(int)YMargin; // offset by the yMargin
|
||||
SKPoint mappedPoint = new SKPoint((int)((sourcePoint.X - XDataExtentMin) * XScalingFactor), (int)(Height - ((sourcePoint.Y - YDataExtentMin) * YScalingFactor)));
|
||||
mappedPoint.X += (int)XMargin; // offset by the xMargin
|
||||
mappedPoint.Y -= (int)YMargin; // offset by the yMargin
|
||||
return mappedPoint;
|
||||
}
|
||||
// TranslatePoint will only translate the given point from an upper left origin system to a bottom left origin system
|
||||
|
||||
Reference in New Issue
Block a user