本文整理汇总了C#中System.Windows.Media.Brush.GetTextureData方法的典型用法代码示例。如果您正苦于以下问题:C# Brush.GetTextureData方法的具体用法?C# Brush.GetTextureData怎么用?C# Brush.GetTextureData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Media.Brush
的用法示例。
在下文中一共展示了Brush.GetTextureData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillPixels
static void FillPixels (
Brush brush, Rect [] rects, int width, int height, ref int [] pixels ) {
if (width < 1 || height < 1)
throw new ArgumentNullException ();
var brushPixels = brush.GetTextureData(width, height);
var getBrushPixel = new Func<int, int, Color>(
(x, y) => {
return new Color { PackedValue = (uint)brushPixels[Math.Min ( y, height - 1 ) * width + x] };
});
foreach (var rc in rects) {
for (var x = (int)rc.Left; x < rc.Right && rc.Right <= width; x++) {
var pixelTopColor = new Color { PackedValue = (uint)pixels [((int)rc.Top) * width + x] };
var pixelBottomColor = new Color { PackedValue = (uint)pixels [((int)rc.Bottom-1) * width + x] };
var topColor = getBrushPixel(x, (int)rc.Top);//brush.GetPixel (x, (int)rc.Top, width, height);
var bottomColor = getBrushPixel(x, (int)rc.Bottom); //brush.GetPixel (x, (int)rc.Bottom, width, height);
// Antialiazing, Top
/*
if (rc.Top > 0 ) {
pixels [((int)rc.Top - 1) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .65f).PackedValue;
}
*/
if (rc.Top > 1) {
pixels [((int)rc.Top - 2) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .38f).PackedValue;
}
for (var y = (int)rc.Top; y < rc.Bottom; y++) {
pixels [y * width + x] = ( int ) ( getBrushPixel ( x, y ) ).PackedValue;
}
// Antialiazing, Bottom
if (rc.Bottom < height)
pixels [((int)rc.Bottom) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .65f).PackedValue;
/*
if (rc.Bottom < height - 1)
pixels [(int)(rc.Bottom + 1) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .38f).PackedValue;
*/
}
}
}