1

当我加载png具有矩形背景的透明图像时ImageBrushWPF图像后面会出现白色背景。它将所有其他内容隐藏回该图像。

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);
}

这是我使用并得到这种输出的代码:

图像获得白色背景,图像后面的墙因白色背景而消失

4

0 回答 0