locked
Universal Apps and InkManager/InkPresenter

    Question

  • Do Windows 8 Universal Apps support Inking on the Phone?  If so how?

    Background:

    I have a couple Windows 8 apps in the windows store that I would like to convert to Universal Apps to release them to the Phone Store.

    I am currently using the InkManager from Windows.UI.Input.Inking in the Windows 8 project.  However the inking namespace is unknown in the Windows Phone project. 

    I've also looked into using InkPresenter but it looks like it also isn't supported in Universal Phone Apps, and is only available in windows phone Silverlight apps.

    I glanced at each of the Universal App Samples and didn't see one that used inking.  (I could have missed it).

    Thursday, September 25, 2014 2:59 PM

Answers

  • Hi sdarbyj1,

    InkManager class is not currently supported in Windows Phone if you read from the documentation.

    I think you may need feedback on http://wpdev.uservoice.com/forums/110705-dev-platform

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, September 26, 2014 5:59 AM
    Moderator

All replies

  • Hi sdarbyj1,

    InkManager class is not currently supported in Windows Phone if you read from the documentation.

    I think you may need feedback on http://wpdev.uservoice.com/forums/110705-dev-platform

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Friday, September 26, 2014 5:59 AM
    Moderator
  • The likely explanation right now is that there simply is no Pen support on any WP device so Inking doesn't make much sense on the phone right now.
    Friday, September 26, 2014 8:26 AM
  • Thanks everyone, I was using Inking for OCR it looks like I will be able to use the Microsoft.Windows.Ocr library instead.  I added it my project using nugets package manager.  I haven't actually tried anything other than compiling with the reference added, and adding the ocrEngine.  That seemed to work.

    See https://www.nuget.org/packages/Microsoft.Windows.Ocr/

    Saturday, September 27, 2014 9:38 PM
  • I simply search for OCR engine: http://blogs.windows.com/buildingapps/2014/09/18/microsoft-ocr-library-for-windows-runtime/

    OCR technology enables various scenarios – copying text from images, text search in images, translation… It was designed with flexibility and performance in mind, as it allows for OCR of high variety of image types and has numerous performance optimizations. The library runs entirely on client, supports 21 languages and enables processing images from various sources – camera, local file or network.

    Looks like it does not support ink too. I don't know if this library have some further relationship with InkManager, perhaps you want to convert image to text?

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Sunday, September 28, 2014 7:38 AM
    Moderator
  • This is the code I came up with it is not a complete sample and I haven't taken the time to clean it up since it isn't working as well for me as I hoped. 

    I am using the pointer events to draw to the canvas.  When the pointer is released I render the canvas to bit map using RenderTargetBitmap to write the canvas to a bitmap and pass that bitmap to the OcrEngine.  The problem for me anyway is it doesn't work as well as the InkManager.  It doesn't appear to recognize individual letters I need to write the whole word to get any recognition and the recognition was not as precise as InkManager.  

            private void OnCanvasPointerPressed(object sender, PointerRoutedEventArgs e)
            {
                PointerPoint pt = e.GetCurrentPoint(canvasSlate);
                ContactPoints.Add(new ContactPoint(pt));
                e.Handled = true;
            }
    
            private void OnCanvasPointerMoved(object sender, PointerRoutedEventArgs e)
            {
                PointerPoint pt = e.GetCurrentPoint(canvasSlate);
                ContactPoint cp = null;
                foreach (ContactPoint lcp in ContactPoints)
                {
                    if (lcp.ID == pt.PointerId)
                        cp = lcp;
                }
                if (cp == null) return;
                if (Distance(pt.Position.X, pt.Position.Y, cp.CurrentPoint.Position.X, cp.CurrentPoint.Position.Y) < 2.0)
                    return;
                cp.Moved(pt);
    
                //Connect this circle to the last circle with a line
                Line line = new Line()
                {
                    X1 = cp.PreviousPoint.Position.X,
                    Y1 = cp.PreviousPoint.Position.Y,
                    X2 = cp.CurrentPoint.Position.X,
                    Y2 = cp.CurrentPoint.Position.Y,
                    StrokeThickness = fCurrentDrawingSize,
                    Stroke = new SolidColorBrush(fCurrentDrawingColor)
                };
                line.Fill = new SolidColorBrush(fCurrentDrawingColor);
                canvasSlate.Children.Add(line);
    
    
                //Add a new circle at the end of the line
                Ellipse circle = new Ellipse();
                SolidColorBrush mySolidColorBrush = new SolidColorBrush();
                mySolidColorBrush.Color = fCurrentDrawingColor;
                circle.Fill = mySolidColorBrush;
                circle.StrokeThickness = 2;
                circle.Stroke = mySolidColorBrush;
                circle.Width = fCurrentDrawingSize;
                circle.Height = fCurrentDrawingSize;
                circle.Margin = new Thickness(pt.Position.X - (fCurrentDrawingSize / 2.0), pt.Position.Y - (fCurrentDrawingSize / 2.0), 0, 0);
                canvasSlate.Children.Add(circle);
                e.Handled = true;
            }
    
            private double Distance(double x1, double y1, double x2, double y2)
            {
                double d = 0;
                d = Math.Sqrt(Math.Pow((x2 - x1), 2) + Math.Pow((y2 - y1), 2));
                return d;
            }
    
            private async void OnCanvasPointerReleased(object sender, PointerRoutedEventArgs e)
            {
                PointerPoint pt = e.GetCurrentPoint(canvasSlate);
                ContactPoint cp = null;
                foreach (ContactPoint lcp in ContactPoints)
                {
                    if (lcp.ID == pt.PointerId)
                        cp = lcp;
                }
                if (cp == null) return;
                ContactPoints.Remove(cp);
    
                RenderTargetBitmap rtb = new RenderTargetBitmap();
                await rtb.RenderAsync(canvasSlate, Convert.ToInt32(canvasSlate.Width), Convert.ToInt32(canvasSlate.Height));
                IBuffer pixelBuffer = await rtb.GetPixelsAsync();
                OcrResult ocrres = await ocrEngine.RecognizeAsync((uint)rtb.PixelHeight, (uint)rtb.PixelWidth, pixelBuffer.ToArray());
                StringBuilder sb = new StringBuilder();
                if (ocrres.Lines != null)
                {
                    foreach (var line in ocrres.Lines)
                    {
                        sb.Clear();
                        // Iterate over words in line. 
                        foreach (var word in line.Words)
                        {
                            if (sb.Length > 0) sb.Append(" ");
                            sb.Append(word.Text);
                        };
                    }
                    rebOCR.Document.SetText(Windows.UI.Text.TextSetOptions.None, sb.ToString().ToLower().Trim());
                }
    
                e.Handled = true;
            }
    

    Monday, September 29, 2014 2:41 AM