2014-09-04 100 views
0

其实我想知道要将图像抹去透明度。就像我在页面背景上有一个图像和上面的另一个图像。现在我想要的是,如果我用手指抹去上面的图像,那么下面的图像应该会出现,简单的说就是说图像会变得透明。我正在做这样的事情,但它不符合我的要求。 您的建议是欢迎:)我们可以在Windows Phone 8中擦除透明吗?

private void Canvas_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) 
{ 

    currentPoint = e.GetPosition(this.canvas); 
    //Initialize line according to currentpoint position. 
    Line line = new Line() 
       { 
        X1 = currentPoint.X, 
        Y1 = currentPoint.Y, 
        X2 = oldPoint.X, 
        Y2 =oldPoint.Y 
       };   


    line.StrokeDashCap = PenLineCap.Round; 
    line.StrokeEndLineCap = PenLineCap.Round; 
    line.StrokeLineJoin = PenLineJoin.Round; 
    line.StrokeThickness = 20; 
    line.Stroke = new SolidColorBrush(Colors.Black) ; 
    //////////////////////////////// 
    //Set color & thickness of line. 

    //Line add in canvas children to draw image & assign oldpoint. 
    this.canvas.Children.Add(line); 
    oldPoint = currentPoint; 
} 
+1

声音有点像重复这个... http://stackoverflow.com/questions/17073357/erase-to-transparency – walther 2014-09-04 10:19:54

+0

@walther不,它不是。这是XAML,而不是GDI。 – 2014-09-04 10:57:01

回答

0

您可以用3周不同的方式做到这一点:

  1. 使用不透明的覆盖和UIElement.Clip财产。但你需要处理Geometry。我担心这将会是非常高的CPU成本。使用WriteableBitmap并更改图像的Alpha通道。你可以使用WriteableBitmapEx

  2. 使用不透明覆盖图和UIElement.OpacityMask属性。我认为这是实现这一点的最佳方式,因为您不限于使用位图(因此您可以将任何XAML控件放置在覆盖图下方),如同第二种方式。

+0

Thankx Eldar !!我很感谢你:)你能解释一下吗,我是新手机开发.. – 2014-09-04 11:40:43

相关问题