WPF, C#, Ink Canvas, Image - How to save inkcanvas on existing image and save it as new image?

StackOverflow https://stackoverflow.com/questions/12874601

Вопрос

I'm trying to make a control where you can paint something on image and save that image with new staff.

At the moment I'm using Ink Canvas because it's really useful control, but I couldn't find how to merge it with background image. Moreover, I don't want InkCanvas to be dropped anywhere in image, I want it to be exactly in that place where it was painted.

Question: How to merge InkCanvas with image?

Current code:

<Grid>
            <Image x:Name="Image_Container"/>
            <InkCanvas Background="Transparent" IsEnabled="False" Width="Auto" Name="inkCanvas" />
</Grid>
Это было полезно?

Решение

<Canvas x:Name="editCanvas" Background="BlanchedAlmond" ClipToBounds="True"> <InkCanvas x:Name="inkCanvas"> <InkCanvas.Background> <ImageBrush Source="C:\Image.png"></ImageBrush> </InkCanvas.Background> </InkCanvas> </Canvas>

Другие советы

XAML Code

<Grid>
     <InkCanvas Name="inkCanvas1" />
</Grid>

C# Code behind

string pathBackgroundimage = "D:/Workspace/Image1.png";
inkCanvas1.IsBackGroundMovable = false;
inkCanvas1.Background = new ImageBrush(new BitmapImage(new Uri(pathBackgroundimage)));
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top