WriteableBitmap Constructor (UIElement, Transform)
Initializes a new instance of the WriteableBitmap class using the provided element and transform.
Assembly: System.Windows (in System.Windows.dll)
- Type: System.Windows.UIElement
The desired element to be rendered within the bitmap.
- Type: System.Windows.Media.Transform
The transform the user wants to apply to the element as the last step before drawing into the bitmap. This is particularly interesting for you if you want the bitmap to respect its transform. This value can be null.
This constructor can be used to cover most "replicate content" scenarios by producing a WriteableBitmap that reduces white space and preserves content. This API will produce a PBGRA32 WriteableBitmap of the element. This WriteableBitmap takes into account many of the properties of child elements below the transform but not properties of parent elements. These properties include:
After rendering the element into an internal intermediate surface, the transform parameter is applied directly. This constructor allows for null to be supplied as the transform.
You may want the transform to be respected, in which case you can call:
WriteableBitmap wb = new WriteableBitmap(btn, btn.RenderTransform);
You may want the layout or perspective to be frozen into the WriteableBitmap, in this case, you can alter your visual tree to include a node above it. With this constructor, you have a way to create a bitmap with just the element, its subtree, and without the offset.