当我在png
矩形背景中加载带ImageBrush
的透明WPF
图像时,我在图像后面会出现白色背景。它将所有其他内容隐藏回该图像。
public void DisplayModel()
{
Uri url = new Uri("pack://application:,,,/Model/01.png");
BitmapImage bmpimg = new BitmapImage();
bmpimg.BeginInit();
bmpimg.UriSource = url;
bmpimg.EndInit();
ImageBrush BrushView = new ImageBrush(bmpimg);
BrushView.AlignmentX = AlignmentX.Right;
BrushView.Stretch = Stretch.Fill;
Material MaterialView = new DiffuseMaterial(BrushView);
MeshGeometry3D mesh_view = new MeshGeometry3D();
double Zdeep = -48;
double x = -30;
double y = -5;
double xEnd = 60;
double yEnd = 45;
//MessageBox.Show(x.ToString()+"-"+y.ToString());
commonObject.makeRectangle(mesh_view, new Point3D(x, y, Zdeep), new Point3D(x + xEnd, y, Zdeep), new Point3D(x + xEnd, yEnd, Zdeep), new Point3D(x, yEnd, Zdeep), new Point(0, 0), new Point(0, 1), new Point(1, 1), new Point(1, 0));
GeometryModel3D ViewGeometry = new GeometryModel3D(mesh_view, MaterialView);
group.Children.Add(ViewGeometry);
}
这里我使用的代码得到了这种输出:
![图像得到白色背景,背后的墙壁因白色背景而消失] [1]