1
我对WPF很陌生,试图将应用程序从VB6移植到C#和XAML。如何在WPF中平铺和叠加图像?
我现在需要做的是创建一个大的图像出来的一些小的,像一系列“瓷砖”排列。其中一些较小的将叠加叠加在它们上面。
在VB6中,完成平铺和叠加只需要在PictureBox控件中使用PaintPicture方法。
这是我在平铺的尝试,并一步到位覆盖(尽管真正的叠加可以事先进行):
ImageDrawing Drawing1 = new ImageDrawing(new BitmapImage(new Uri(@"c:\one.bmp",
UriKind.Absolute)),
new Rect(0, 0, 40, 130));
ImageDrawing Drawing2 = new ImageDrawing(new BitmapImage(new Uri(@"c:\two.bmp",
UriKind.Absolute)),
new Rect(40, 0, 45, 130));
ImageDrawing Drawing3 = new ImageDrawing(new BitmapImage(new Uri(@"c:\overlay.bmp",
UriKind.Absolute)),
new Rect(40, 0, 45, 130));
DrawingGroup myDrawingGroup = new DrawingGroup();
myDrawingGroup.Children.Add(Drawing1);
myDrawingGroup.Children.Add(Drawing2);
myDrawingGroup.Children.Add(Drawing3);
myImage.Source = new DrawingImage(myDrawingGroup);
平铺工作正常,但覆盖是一个没有去。我在想,如果
- 有人能指出我朝着实现的覆盖和
- 有人能指出这是做瓷砖的最好方法的手段。
谢谢!!