microsoft / Win2D

Win2D is an easy-to-use Windows Runtime API for immediate mode 2D graphics rendering with GPU acceleration. It is available to C#, C++ and VB developers writing apps for the Windows Universal Platform (UWP). It utilizes the power of Direct2D, and integrates seamlessly with XAML and CoreWindow.
http://microsoft.github.io/Win2D
Other
1.8k stars 284 forks source link

CanvasDrawingSession.DrawInk() doesn't draw Highlighter ink in CanvasCommandList #462

Closed mscherotter closed 7 years ago

mscherotter commented 7 years ago

Ink that has InkDrawingAttributes.DrawAsHighlighter=true will draw fine when used directly like this session.DrawInk(ink);

but will not draw when used in a command list session: using (var list = new CanvasCommandList(session)) { using (var listSession = list.CreateDrawingSession()) { listSession.DrawInk(ink); }

session.DrawImage(list);

}

shawnhar commented 7 years ago

The problem is not with the command list itself, but with the blend mode you are using when later drawing the command list image. Highlighter ink uses a min blend mode, but by default your DrawImage call will be using standard sourceover blend. You'll need to configure that DrawImage call to match the blend operations used by the highlighter rendering, which as far as I know are not documented anywhere :-(

In general, highlighter ink is best drawn directly over whatever image you want it to highlight. Trying to cache this kind of ink in intermediate surfaces gets surprisingly complex.

See issue #428 and http://stackoverflow.com/questions/36397638/win2d-uwp-wont-save-a-highlight-stroke-in-an-inkcanvas/36509014#36509014 for discussion of similar issues.