Taking alook at DrawText in the ImageHelper.

This commit is contained in:
2025-06-29 17:01:07 -04:00
parent 7c3e15ee57
commit 9fc8e613f1

View File

@@ -525,7 +525,35 @@ namespace MarketData.CNNProcessing
paint.Color = color;
canvas.DrawText(text,srcPoint, align, font, paint);
}
public void DrawBoundedText(String text, SKPoint srcPoint, SKColor color, SKTextAlign align, SKFont font,SKPaintStyle paintStyle=SKPaintStyle.Fill,float strokeWidth = 1)
{
// Validate();
// SKPoint txSrcPoint = pointMapping.MapPoint(srcPoint);
using SKPaint paint = new SKPaint();
paint.Style = paintStyle;
paint.StrokeWidth = strokeWidth; // Set the desired stroke width
paint.Color = color;
SKRect rect = new SKRect(0, 0, 0, 0);
float textSize = font.MeasureText(text,out rect,paint);
CreateImage((int)rect.Width+1,(int)rect.Height+1);
SKPoint txSrcPoint = pointMapping.MapPoint(srcPoint);
using SKCanvas canvas = new SKCanvas(bitmap);
canvas.DrawText(text,srcPoint, align, font, paint);
}
// float textSize = fonts[0].MeasureText(displayText,out rect,SKPaint);
// imageHelper.CreateImage(width, height);
// imageHelper.Fill(SKColors.White);
// imageHelper.DrawLine(SKColors.Black, 1, new SKPoint(0, 0), new SKPoint(width - 1, 0)); // bottom left to right
// imageHelper.DrawLine(SKColors.Black, 1, new SKPoint(width - 1, 0), new SKPoint(width - 1, height - 1)); // up lefthand side
// imageHelper.DrawLine(SKColors.Black, 1, new SKPoint(0, height - 1), new SKPoint(width - 1, height - 1)); // top left to right
// imageHelper.DrawLine(SKColors.Black, 1, new SKPoint(0, height - 1), new SKPoint(0, 0)); // left hand side top to bottom
// imageHelper.DrawText(displayText, new SKPoint(2, 16), SKColors.White, align, fonts[index]);
/// <summary>
/// Draws the path along the line segments
/// </summary>