2010-11-19 16 views
0

我想設置從用戶在屏幕上繪圖獲得的筆畫的不透明度。我可以得到繪圖,大小,筆劃的輪廓來設置,但不是它的不透明度。在Silverlight 4中:如何以編程方式設置筆觸的不透明度?

這是我的代碼

StylusPointCollection spTemp = e.StylusDevice.GetStylusPoints(MyIP); 
     tempStroke.StylusPoints.Add(spTemp); 

     tempStroke.DrawingAttributes.Color = Colors.Red; 
     tempStroke.DrawingAttributes.OutlineColor = Colors.Black; 

     tempStroke.DrawingAttributes.Width = BrushSize.Value; 
     tempStroke.DrawingAttributes.Height = BrushSize.Value; 

     MyIP.Strokes.Add(tempStroke); 

任何幫助表示讚賞

簡單代碼

回答

2

在顏色上設置alpha值。例如對於+ -0.5的不透明度和紅色:

tempStroke.DrawingAttributes.Color = Colors.FromArgb(125,255,0,0); 
1

我認爲你將不得不設置在Alpha上的顏色。 例如:

//the first 00 would be your alpha channel, then red, then green, then blue 
tempStroke.DrawingAttributes.Color = Colors.FromArgb(0x00,0xFF,0x00,0x00); 
相關問題