I have an InkCanvas where strokes are collected.
StrokeCollection selectedStrokes = ic.GetSelectedStrokes();
to get the selected strokes and the bounds of just those selected strokes.
what is the best method to capture just the visual of those strokes --not the entire canvas--and their bounding rect so as to directly convert them into a bitmap?
Any help or suggestions are appreciated.
The closest I can find is:
Matrix m =
PresentationSource.FromVisual(canvas).CompositionTarget.TransformToDevice;
But this does not give me just the rectangle surrounding the strokes; infact, nothing showed up at all. (It failed).
I am in WPF C# .net 4.0
Edit: I'm trying to avoid using the strokes as an UI element, and stay strictly with the visual.
I also tried:
RectangleGeometry myRectangleGeometry = new RectangleGeometry();
myRectangleGeometry.Rect = inkBounds;
InkCanvas.Clip = myRectangleGeometry;
Which also fails.
Even doing RenderTargetBitmap.Render(InkCanvas) fails!
The articles mentioned only seem to work for UI elements -- is there a way to use strictly what is visually painted on the screen? (I am totally lost at this point).