0

I want to draw some images on to existing canvas using multiply blend mode. However, I don't know how to do it as the BlendEffect class require me to assign the Background variable but that is suppose to be the canvas which I could not put there.

    private void OnDrawCanvas(CanvasControl sender, CanvasDrawEventArgs args)
    {
        var list = new LinkedList<ImageNode>();
    
        mRootNode.GetTraverseList(list, false);
    
        foreach (var item in list)
        {
            if (!item.treeVisible)
                continue;
            
            if (item.mLayerPixels != null)
            {
                if (item.mLayer.BlendModeKey == BlendModeType.MULTIPLY)
                {
                    var blendEffect = new BlendEffect()
                    {
                        //Background = ???, // what to put????
                        Foreground = item.mLayerPixels,
                        Mode = BlendEffectMode.Multiply
                    };
                    args.DrawingSession.DrawImage(blendEffect, item.mLayer.Left, item.mLayer.Top);
                }
                else
                {
    
                    args.DrawingSession.DrawImage(item.mLayerPixels, item.mLayer.Left, item.mLayer.Top);
                }
            }
        }
    
    }

1 Answer 1

0

I ended up creating an offscreen CanvasRenderTarget to do the blending. When all the drawing is done, I create a CanvasBitmap from CanvasRenderTarget which allow me to draw the final result to the UI with args.DrawingSession.DrawImage();

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.