//Gray:黑白 private void GrayButton_Tapped(object sender, TappedRoutedEventArgs e) { flyout.Hide(); Layer l = App.Model.Layers[App.Model.Index]; //如果图层不可视或透明 if (l.Visual == false || l.Opacity <= 0) { App.Tip(App.resourceLoader.GetString("/Layer/Hided_")); } else { //Undo:撤销 Undo undo = new Undo(); undo.TargeInstantiation(App.Model.Index, App.Model.CurrentRenderTarget); App.UndoAdd(undo); using (CanvasDrawingSession ds = l.CanvasRenderTarget.CreateDrawingSession()) { if (App.Model.isAnimated == false) //清空:如果无选区 { ds.Clear(Colors.Transparent); } else if (App.Model.isAnimated == true) //选区内清空:如果有选区 { ds.DrawImage(App.Model.MaskRenderTarget, 0, 0, App.Model.MaskRenderTarget.Bounds, 1, CanvasImageInterpolation.Linear, CanvasComposite.DestinationOut); } ds.DrawImage(Adjust.GetGrayscale(App.Model.SecondSourceRenderTarget)); //绘画:特效渲染目标 } l.SetWriteableBitmap(App.Model.VirtualControl); //刷新缩略图 App.Model.isReRender = true; //重新渲染 App.Model.Refresh++; //画布刷新 } }