Search code examples
c#uwpfullscreeninkcanvas

How to save a full-screen ink file in uwp?


I have a question about saving ink file (including ink's meta data file .gif) in uwp.

(ink means that something user drawn)

Currently, I can only save the range of ink that it's part of the inkcanvas, not full - screen inkcanvas

inkcanvas.InkPresenter.StrokeContainer.SaveAsync(outputStream);

This way only saves the ink, not inkcanvas's full-screen.

I want to show the ink and full-screen to user, so I need a ink and full-screen

Is this way possible?

Please any help! Thanks


Solution

  • A workaround for this is drawing 2 invisible dots to the canvas, one at the upper-left corner, one at the bottom-right corner.

    Add them before the call to StrokeContainer.SaveAsync.

    private void AddInvisibleDotsAtCorners()
    {
        var inkStrokeBuilder = new InkStrokeBuilder();
        var stroke1 = inkStrokeBuilder.CreateStrokeFromInkPoints(
            new InkPoint[] 
            {
                new InkPoint(new Point(0, 0), 0.0f)
            }, System.Numerics.Matrix3x2.Identity);
    
        var stroke2 = inkStrokeBuilder.CreateStrokeFromInkPoints(
            new InkPoint[]
            {
                new InkPoint(new Point(inkCanvas.ActualWidth, inkCanvas.ActualHeight), 0.0f)
            }, System.Numerics.Matrix3x2.Identity);
        inkCanvas.InkPresenter.StrokeContainer.AddStroke(stroke1);
        inkCanvas.InkPresenter.StrokeContainer.AddStroke(stroke2);
    }
    

    then remove them after the call StrokeContainer.SaveAsync is completed.