none
How can i save the InkCanvas stroke for Image control? RRS feed

  • Question

  •  How can i save the InkCanvas stroke for Image control?

    where the Image control is in gridview , when the user draws strokes on the InkCanvas exit in the Image control.

    indows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;`enter 
    
    Windows.Storage.StorageFile file = await storageFolder.CreateFileAsync("sample.gif", Windows.Storage.CreationCollisionOption.ReplaceExisting);
    
    Windows.Storage.CachedFileManager.DeferUpdates(file);
    
    IRandomAccessStream stream = await file.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite);
    using (IOutputStream outputStream = stream.GetOutputStreamAt(0)) {
       await inkCanvas.InkPresenter.StrokeContainer.SaveAsync(outputStream);
       await outputStream.FlushAsync();
    }
    stream.Dispose();
    
    Windows.Storage.Provider.FileUpdateStatus status = await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
    
    if (status == Windows.Storage.Provider.FileUpdateStatus.Complete
    {
         // File saved
    } else {
         // File NOT saved
    }`

    Wednesday, October 17, 2018 9:29 AM

All replies

  • Hello Javier Ra,

    If I understand correctly you want to draw your inks into a image, am I right on this? To save your inks you can use win2d, and here is the official doc:

    https://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_CanvasDrawingSession_DrawInk.htm

    You can also have a look at this SO thread who has provided detailed code about how to do this.

    Best regards,

    Barry 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 18, 2018 5:12 AM
    Moderator
  • When the user draws in inkcanvas is recorded in the gridView and then open it in the InkCanvas
    Sunday, October 21, 2018 4:39 PM
  • @Javier:

    When the user draws in inkcanvas is recorded in the gridView.

    So record in grid means what? Record to a image?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 22, 2018 7:12 AM
    Moderator
  • Yes, when you record it becomes an image that is recorded in the GridView . example would be Coloring Book.
    Wednesday, October 24, 2018 8:17 PM
  • @Javier,

    Then what I suggest should be the same, use rendertargetbitmap from UWP API to render your GridView, then draw inks with Win2D api over the exist image. After that you will get the full image, have you gave it a test?

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 25, 2018 7:44 AM
    Moderator
  • Hello:

    Problem is that later I want to save it in the folder Assets has part of the renderTargetBitmap.

    Thursday, October 25, 2018 12:09 PM
  • @Javier Ra,

    So you want ink itself without any other bitmap? Screenshot or code is better for me to understand what happens.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 30, 2018 9:29 AM
    Moderator
  • Tuesday, October 30, 2018 10:00 AM
  • hello: StartoverFlow  This is for me to do this part
    Friday, December 21, 2018 8:35 AM
  • this problem whit  Constants 

    This can be used to record the stroke

    ink


    • Edited by Javier Ra Tuesday, January 8, 2019 11:25 AM more information
    Monday, December 31, 2018 9:02 AM