[英]Change InkDrawingAttributes Opacity for Pen brush
我使用顏色選擇器用筆繪圖,但使用此代碼我無法更改筆顏色的不透明度:
InkDrawingAttributes inkDrawingAttributes = InkCanvas.InkPresenter.CopyDefaultDrawingAttributes(); inkDrawingAttributes.Color = ColorPenSelected; InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(inkDrawingAttributes);
但是,使用 InkCanvas.InkPresenter.CopyDefaultDrawingAttributes() inkDrawingAttributes.PencilProperties 是 null,我無法更改不透明度。 不允許更改不透明度。
我可以用這段代碼改變不透明度:
InkDrawingAttributes inkDrawingAttributes = InkDrawingAttributes.CreateForPencil(); inkDrawingAttributes.Color = ColorPenSelected; inkDrawingAttributes.PencilProperties.Opacity = (double)ColorPenSelected.A * 5 / 255; InkCanvas.InkPresenter.UpdateDefaultDrawingAttributes(inkDrawingAttributes);
在 CreateForPencil() 中用作鉛筆。
現在,我可以更改不透明度。 然而,與第一張圖像相比,畫筆紋理不同,即使使用 100% 的不透明度。 線上有很多點,而不是一條獨特的線:
那么,如何更改鋼筆畫筆的不透明度並保持與第一張圖像相同的紋理? 有一條連續的線,沒有第二張圖片中的點。
我最初認為您可以將inkDrawingAttributes.Color
設置為 ARGB 值,但由於以下原因這是不可能的。
Color 的值是一個 ARGB 值。 但是,透明度組件(A 或 alpha 通道)的值將被忽略,InkStroke 將以完全不透明的方式呈現。
恐怕這似乎是不可能的。 您也許可以在之后將筆划渲染為半透明 - 但似乎您無法設置筆的不透明度。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.