public override void DrawImage(object backend, ImageDescription img, double x, double y)
        {
            var      c   = (DrawingContext)backend;
            WpfImage bmp = (WpfImage)img.Backend;

            bmp.Draw(ApplicationContext, c.Context, c.ScaleFactor, x, y, img);
        }
예제 #2
0
        public override void RenderImage(object nativeWidget, object nativeContext, ImageDescription img, double x, double y)
        {
            WpfImage im = (WpfImage)img.Backend;

            System.Windows.Media.DrawingContext dc = nativeContext as System.Windows.Media.DrawingContext;
            FrameworkElement w = (FrameworkElement)nativeWidget;

            if (dc != null)
            {
                im.Draw(ApplicationContext, dc, Util.GetScaleFactor(w), x, y, img);
            }
        }
        public override void DrawImage(object backend, ImageDescription img, Rectangle srcRect, Rectangle destRect)
        {
            var      c   = (DrawingContext)backend;
            WpfImage bmp = (WpfImage)img.Backend;

            c.Context.PushClip(new RectangleGeometry(destRect.ToWpfRect()));
            c.Context.PushTransform(new TranslateTransform(destRect.X - srcRect.X, destRect.Y - srcRect.Y));
            var sw = destRect.Width / srcRect.Width;
            var sh = destRect.Height / srcRect.Height;

            c.Context.PushTransform(new ScaleTransform(sw, sh));
            bmp.Draw(ApplicationContext, c.Context, c.ScaleFactor, 0, 0, img);

            c.Context.Pop();              // Scale
            c.Context.Pop();              // Translate
            c.Context.Pop();              // Clip
        }