1

I work on a UWP app where the user must be able to take a photo from the camera, and add details by drawing some shapes. I think the simplest way to do this is using the InkToolbar. So I've donwloaded the official sample: SimpleInk

But I don't see how to solve some of my needs:

  • add a background image to the InkCanvas: I would like get a BitmapImage containing the original photo and the items drawed by the user

=> is it possible to do this properly? or do I need to superpose the Image and the InkCanvas in the Grid and take a screenshot?

  • draw basic shapes like circles or rectangles: all the samples are based on hand drawing with different kinds of pencils

=> is there a way to draw shapes like circles or rectangles through this control? or what is the better way for allowing user to "draw" shapes easily?

I also looked at the Win2D samples Win2D-samples, but I didn't found a similar case.

Thanks in advance for your feedbacks!

Gold.strike
  • 1,269
  • 13
  • 47

1 Answers1

1

add a background image to the InkCanvas: I would like get a BitmapImage containing the original photo and the items drawed by the user

The InkCanvas doesn't contain a background property directly. You can create an InkCanvas overlays a background image by using an Image control like the Basic inking with InkCanvas sample shows.

But if you need to get a new BitmapImage from original image with InkCanvas drawing you need to use the Win2D library. For more details and a completed demo please reference this thread.

draw basic shapes like circles or rectangles: all the samples are based on hand drawing with different kinds of pencils

For this, the UAP sample of Win2D-samples you mentioned above provided a demo for drawing a circle you can reference(same with rectangles like follows).

args.DrawingSession.DrawEllipse(155, 115, 80, 30, Colors.Black, 3);    
args.DrawingSession.DrawRectangle(155, 115, 80, 30, Colors.Black);

The official Complex inking sample also provide the Insert a shape feature you can test and reference.

Community
  • 1
  • 1
Sunteen Wu
  • 10,509
  • 1
  • 10
  • 21
  • Thanks for your feedback. But I need to draw the shapes manually: by drag and drop or a click, and then adjust the size by moving the ends of the shape (like with the decorators in WPF). Is this easily feasable in an UWP app? I found a componenant that must allowing me to do this: https://www.syncfusion.com/products/uwp/diagram But the final customer must bought a license... – Gold.strike Oct 20 '16 at 13:04