本文介绍了为什么不工作TranslateTransform?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好!

我有问题。

使用:



Hello!
I have problem.
Using:

TransformedBitmap transformedBmp = new TransformedBitmap(new BitmapImage(new Uri("c:\\1.png")), new System.Windows.Media.TranslateTransform(50, 90));



但是图像没有移动,为什么?


But image not moving, why?

推荐答案

private RenderTargetBitmap DrawImage(BitmapImage overlayImageclear, BitmapImage overlayImage, Rect oper,Rect oper2)
     {
         var drawingVisual = new DrawingVisual();
         var drawingContext = drawingVisual.RenderOpen();
         //drawingContext.DrawImage(BitmapSource.Create(colorFrame.Width, colorFrame.Height, 96, 96, PixelFormats.Pbgra32, null, colorData, colorFrame.Width * colorFrame.BytesPerPixel), new Rect(new Size(colorFrame.Width, colorFrame.Height)));
         // var overlayImageclear = new BitmapImage(new Uri("c:\\2.png"));
         drawingContext.DrawImage(overlayImageclear, new Rect(0, 0, overlayImageclear.Width, overlayImageclear.Height));
         // var overlayImage = new BitmapImage(new Uri("c:\\1.png"));
         drawingContext.DrawImage(overlayImage, new Rect(oper.X, oper.Y, overlayImage.Width * (1.0 + oper2.X), overlayImage.Height * (1.0 + oper2.Y)));
         drawingContext.Close();
         var mergedImage = new RenderTargetBitmap((int)overlayImageclear.Width, (int)overlayImageclear.Height, 96, 96, PixelFormats.Pbgra32);
         mergedImage.Render(drawingVisual);
         return (RenderTargetBitmap)mergedImage;
         // MainPB2.Source = mergedImage;
     }



谢谢,Sergey Alexandrovich Kryukov。 ИсНовымГодом!


Thanks, Sergey Alexandrovich Kryukov. И с Новым Годом!



这篇关于为什么不工作TranslateTransform?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 08:28