本文整理匯總了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;
*/
}
}
}