0

I have Application with standard Inkcanvas. Standard Application looks like Figure 1. and all application code (XAML) is here:

<Window x:Class="WpfApplication18.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525">
<Grid>
    <InkCanvas>
        <InkCanvas.DefaultDrawingAttributes>
            <DrawingAttributes x:Name="attribute" Width="40" Height="40" Color="BlueViolet" />
        </InkCanvas.DefaultDrawingAttributes>
    </InkCanvas>
</Grid>

I am wondering how to create non standard Inkcanvas Brush with Image (Image Mask?) like this: Figure 2. I want to Paint with use of Inkcanvas and simple "background" image (jpg, png or whatever). Is there a simple way to make it? Can you give example with a code?

In my application I want to paint on standard Inkcanvas and after that convert Inkcanvas selection to achieve something like this Figure 2. (after clicking on a button?)

2 Answers2

0

There is no simple way because ink only supports strokes with a solid color.

It might prove to be easier to create a custom canvas that you paint on with an ImageBrush That is a lot of work if you want to create a full replica of the inkcanvas but it might be not that bad you you just need to be able to draw some lines.

I thought about putting an image below the inkcanvas and painting with a transparent color on the inkcanvas but that will not make the background of the inkcanvas transparent.

Emond
  • 50,210
  • 11
  • 84
  • 115
0

Although this is an old thread, I still would like to point out this sample at MSDN.

I've checked it with NET 4.0 + VS 2010 + Windows 7 x64 and it works all right (as in this image). It seems to do exactly what the OP has requested.

It uses a DynamicRenderer (msdn.microsoft.com/en-us/library/vstudio/system.windows.input.stylusplugins.dynamicrenderer(v=vs.100).aspx) to achieve this, right in the InkCanvas without additional processing.

There are also some additional customizations you can do with InkCanvas (msdn.microsoft.com/en-us/library/vstudio/system.windows.controls.inkcanvas(v=vs.100).aspx) :

  • Ink Handling (msdn.microsoft.com/en-us/library/vstudio/ms752076(v=vs.100).aspx)
  • Custom Rendering (msdn.microsoft.com/en-us/library/vstudio/ms747347(v=vs.100).aspx)
  • Additional Samples (msdn.microsoft.com/en-us/library/vstudio/aa972145(v=vs.90).aspx).

Regards, Hakan.

Hakan Çelik Mk1
  • 419
  • 4
  • 11