public static void DrawAsBitmap(SKCanvas canvas, LabelStyle style, IFeature feature, float x, float y, float layerOpacity) { var text = style.GetLabelText(feature); var key = text + "_" + style.Font.FontFamily + "_" + style.Font.Size + "_" + (float)style.Font.Size + "_" + style.BackColor + "_" + style.ForeColor; if (!LabelCache.Keys.Contains(key)) { LabelCache[key] = new BitmapInfo { Bitmap = CreateLabelAsBitmap(style, text, layerOpacity) } } ; var info = LabelCache[key]; BitmapHelper.RenderBitmap(canvas, info.Bitmap, (int)Math.Round(x), (int)Math.Round(y), offsetX: (float)style.Offset.X, offsetY: (float)-style.Offset.Y, horizontalAlignment: style.HorizontalAlignment, verticalAlignment: style.VerticalAlignment); }
private static void DrawContent(CalloutStyle callout, SKCanvas canvas, BitmapInfo bitmapInfo) { // Draw content if (callout.Content >= 0) { var strokeWidth = callout.StrokeWidth < 1 ? 1 : callout.StrokeWidth; var offsetX = callout.ShadowWidth + strokeWidth * 2 + (callout.Padding.Left < callout.RectRadius * 0.5 ? callout.RectRadius * 0.5f : (float)callout.Padding.Left); var offsetY = callout.ShadowWidth + strokeWidth * 2 + (callout.Padding.Top < callout.RectRadius * 0.5 ? callout.RectRadius * 0.5f : (float)callout.Padding.Top); switch (callout.ArrowAlignment) { case ArrowAlignment.Left: offsetX += callout.ArrowHeight; break; case ArrowAlignment.Top: offsetY += callout.ArrowHeight; break; } var offset = new SKPoint(offsetX, offsetY); switch (bitmapInfo.Type) { case BitmapType.Bitmap: canvas.DrawImage(bitmapInfo.Bitmap, offset); break; case BitmapType.Sprite: throw new Exception(); case BitmapType.Svg: canvas.DrawPicture(bitmapInfo.Svg.Picture, offset); break; } } }