【问题标题】:Better way to overlap (superimpose) images in WPF?在 WPF 中重叠(叠加)图像的更好方法?
【发布时间】:2011-02-07 09:05:06
【问题描述】:

我需要在 WPF 中为一个项目叠加两个图像。在四处搜索时,我终于按照这里的建议使用了使用 DrawingGroup 的 DrawingImage 类:Overlay two bitmap images in WPF

var group = new DrawingGroup();
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(@"...\Some.jpg", UriKind.Absolute)), new Rect(0, 0, ??, ??)));
group.Children.Add(new ImageDrawing(new BitmapImage(new Uri(@"...\Some.png", UriKind.Absolute)), new Rect(0, 0, ??, ??)));

MyImage.Source = new DrawingImage(group);

但我遇到了困难,因为我无法将其转换回 BitmapImage 以进行进一步操作。

关于 WPF 中重叠图像的任何其他想法?

【问题讨论】:

  • 你想达到什么目的?为什么需要转换回来?
  • 我想旋转,将图像与其他图像合并并打印最终输出。
  • 您可以将RotateTransform 应用到您的DrawingGroupmsdn.microsoft.com/en-us/library/…。您可以嵌套DrawingGroups,获得任何想要的效果。这样可以避免转换回来。

标签: c# wpf


【解决方案1】:

我能够使用 DrawingVisual 类完成我的要求。欲了解更多信息,请参阅此处:Drawing Bitmaps – DrawingImage and DrawingVisual

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多