Share via


Visual.IsPixelSnappingEnabled 屬性

定義

取得或設定值,這個值表示組合引擎是否對齊轉譯的視覺效果與圖元界限。

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;
}

備註

圖元貼齊可讓您要求組合引擎在轉譯時間稍微調整視覺化樹狀結構的位置,使其原點與圖元界限完美對齊。 這會犧牲位置精確度,以交換紋理的縮減取樣成品。

適用於