3
我就與不同的不透明度值的矩形組,並添加這些矩形網格中的WindowsPhone:如何將UIControl以不透明方式正確保存到WriteableBitmap?
var grid=new Grid();
grid.Width = grid.Height = 200;
var rectanglesCount=55;
var rectangleSizeStep = grid.Height/rectanglesCount;
var opacityStep = 1.0/rectanglesCount
var rectangleSize = grid.Height;
var opacity = 0.0;
for (int i = 0; i <= rectanglesCount; i++)
{
Rectangle rect = new Rectangle();
rect.Height = rect.Width = rectangleSize;
rect.VerticalAlignment = VerticalAlignment.Center;
rect.HorizontalAlignment = HorizontalAlignment.Center;
rect.Fill = new SolidColorBrush(Colors.Yellow);
rect.Opacity = opacity;
opacity += opacityStep;
rectangleSize -= rectangleSizeStep;
grid.Children.Add(rect);
}
我能在網看到下面的圖片:
後,我試圖挽救這個組的矩形到WriteableBitmap的並顯示爲圖片:
var img=new Image();
var wrBit = new WriteableBitmap(grid, null);
img.Source=wrBit;
而且我看到的畫面:
什麼發生在頂部和左邊的不透明度? 如何正確保存一組矩形?