public void StrokePropertyValuesAreCorrect() { var paint = new SKPaint(); paint.IsStroke = true; Assert.IsTrue(paint.IsStroke); paint.IsStroke = false; Assert.IsFalse(paint.IsStroke); }
public SKImage BurnIn(string fileName) { //read all images into memory SKImage finalImage = null; //create a bitmap from the file and add it to the list SKBitmap bitmap = SKBitmap.Decode(fileName); try { int width = 0; int height = 0; //update the size of the final bitmap width += bitmap.Width; height += bitmap.Height; //get a surface so we can draw an image using (var tempSurface = SKSurface.Create(new SKImageInfo(width, height))) { //get the drawing canvas of the surface var canvas = tempSurface.Canvas; //set background color canvas.Clear(SKColors.Transparent); //go through each image and draw it on the final image int offset = 0; int offsetTop = 0; canvas.DrawBitmap(bitmap, SKRect.Create(offset, offsetTop, bitmap.Width, bitmap.Height)); offsetTop = offsetTop > 0 ? 0 : bitmap.Height / 2; offset += (int)(bitmap.Width / 1.6); SKPaint textPaint = new SKPaint { Color = LabelColor, TextSize = TextFontSize * (float)DisplayScaleFactor, TextAlign = SKTextAlign.Center, Typeface = SKTypeface.FromFamilyName("Segoe UI", SKTypefaceStyle.Normal) }; SKPaint thinLinePaint = new SKPaint { Style = SKPaintStyle.Stroke, Color = LineColor, StrokeWidth = 2 * (float)DisplayScaleFactor }; int displayLength = DisplayLength; //1/5 to 1/10 of image //IMPORTANT:length is calculated without display scale factor int length = GetScreenDrawLength(DisplayLength); int left = 16; var x = left + (int)(length / 2.0); var y = 25;//(int)height - 20 * (float)DisplayScaleFactor; // Display text canvas.DrawText($@"{displayLength:0} {ScaleUnit}", x, y, textPaint); // Display thick line float scaleFactor = (float)DisplayScaleFactor; canvas.DrawLine(left, 5 * scaleFactor, left, 20 * scaleFactor, thinLinePaint); //left canvas.DrawLine(left + 2, 15 * scaleFactor, left + length - 2, 15 * scaleFactor, thinLinePaint); //middle canvas.DrawLine(left + length, 5 * scaleFactor, left + length, 20 * scaleFactor, thinLinePaint); //right // return the surface as a manageable image finalImage = tempSurface.Snapshot(); } //return the image that was just drawn return(finalImage); } finally { bitmap.Dispose(); } }