当我加载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);
}
这是我使用并得到这种输出的代码: