Ejemplo n.º 1
0
        public static BitmapSource DrawRoundStart(BitmapSource baseImage, IRound round, int roundNum)
        {
            Action <DrawingContext, double> drawAction = (drawingContext, annotationScale) =>
            {
                var image    = round.GetRoundTemplateImage();
                var faceRect = new Rect(0, 0, baseImage.Width, baseImage.Height);
                //faceRect.Inflate(6 * annotationScale, 6 * annotationScale);

                drawingContext.DrawImage(image, faceRect);

                FormattedText targetText = new FormattedText(round.GetRoundImageText(),
                                                             CultureInfo.CurrentCulture, FlowDirection.LeftToRight, s_typeface, 30, Brushes.White);

                var targetPoint = new System.Windows.Point(70, 160);
                drawingContext.DrawText(targetText, targetPoint);

                FormattedText roundNmberText = new FormattedText(roundNum.ToString(),
                                                                 CultureInfo.CurrentCulture, FlowDirection.LeftToRight, s_typeface, 40, Brushes.White);

                var roundNumberPoint = new System.Windows.Point(200, 16);
                drawingContext.DrawText(roundNmberText, roundNumberPoint);
            };

            return(DrawOverlay(baseImage, drawAction));
        }
Ejemplo n.º 2
0
        public static ImageSource DrawTime(string showTime, bool drawIndicator, IRound round)
        {
            if (lastBitmap == null)
            {
                return(lastBitmap);
            }
            DrawingVisual visual = new DrawingVisual();



            DrawingContext drawingContext = visual.RenderOpen();

            FormattedText ft = new FormattedText(showTime,
                                                 CultureInfo.CurrentCulture, FlowDirection.LeftToRight, s_typeface,
                                                 50, Brushes.White);

            drawingContext.DrawImage(lastBitmap, new Rect(0, 0, lastBitmap.Width, lastBitmap.Height));

            drawingContext.DrawText(ft, new Point(550, 0));

            if (drawIndicator)
            {
                drawingContext.DrawImage(round.GetRoundIndicator(), new Rect(20, 20, 100, 100));

                FormattedText targetText = new FormattedText(round.GetRoundImageText(),
                                                             CultureInfo.CurrentCulture, FlowDirection.LeftToRight, s_typeface,
                                                             20, Brushes.White);

                drawingContext.DrawText(targetText, new Point(55, 75));
            }
            drawingContext.Close();

            RenderTargetBitmap outputBitmap = new RenderTargetBitmap(
                (int)lastBitmap.Width, (int)lastBitmap.Height,
                0, 0, PixelFormats.Pbgra32);

            outputBitmap.Render(visual);

            return(outputBitmap);
        }