Visual.IsPixelSnappingEnabled 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定一個值,指示合成引擎是否將渲染的視覺元素與像素邊界對齊。
public:
property bool IsPixelSnappingEnabled { bool get(); void set(bool value); };
bool IsPixelSnappingEnabled();
void IsPixelSnappingEnabled(bool value);
public bool IsPixelSnappingEnabled { get; set; }
var boolean = visual.isPixelSnappingEnabled;
visual.isPixelSnappingEnabled = boolean;
Public Property IsPixelSnappingEnabled As Boolean
屬性值
Boolean
bool
true如果合成引擎將渲染的視覺元素與像素邊界對齊;否則,。 false 預設值為 false。
範例
public Visual CreateVisualTree(Compositor compositor)
{
// Say we have two visuals, one containing an image and one containing text.
// The image can be resampled and still look fine, but the text looks bad if
// it doesn't land perfectly on pixel boundaries.
var root = compositor.CreateContainerVisual();
var imageVisual = compositor.CreateSpriteVisual();
ImageLoadingHelper(imageVisual);
var textVisual = compositor.CreateSpriteVisual();
TextLoadingHelper(textVisual);
textVisual.Offset = new Vector3(50, 0, 0);
textVisual.IsPixelSnappingEnabled = true;
root.Children.Add(imageVisual);
root.Children.Add(textVisual);
return root;
}
備註
像素吸附讓你在渲染時請求合成引擎稍微調整視覺樹的位置,使其原點與像素邊界完美對齊。 這犧牲了位置精度,換取紋理取樣失真減少。