Click here to Skip to main content
15,791,229 members

Comments by daphne35 (Top 4 by date)

daphne35 13-Feb-14 4:32am View    
Here are some parts of the code :

In the Xaml file :

<window.datacontext>
<local:displayviewmodel>


<inkcanvas grid.row="1" x:name="myInkcanvas0">
<Image x:Name="img0" Source="{Binding Path0}" />

<inkcanvas grid.row="1" x:name="myInkcanvas1">
<Image x:Name="img1" Source="{Binding Path1}"/>


<Button Content="Save" Click="Save"/>


In the main cs file :

private void Save(object sender, RoutedEventArgs e)
{
SaveFile(((DisplayViewModel)this.DataContext).Path0, myInkcanvas0);
SaveFile(((DisplayViewModel)this.DataContext).Path0, myInkcanvas1);
}

private void SaveFile(string sPath, InkCanvas cnv)
{
FileStream stream = new FileStream(sPath, FileMode.Open, FileAccess.ReadWrite);
RenderTargetBitmap rtb = new RenderTargetBitmap(1200, 300, 0, 0, PixelFormats.Default);
rtb.Render(cnv);

BmpBitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
encoder.Save(stream);
stream.Close();

}

--> Exception : the process can not access to the file myfile.png because it is used by another process.
daphne35 30-Jan-14 4:29am View    
Thank you for your reply. I want this verification takes place at the same time the plot. You think it will work?
Moreover squares are part of the Strokes, I can get the coordinates of each square of the Stroke?
Thanks
daphne35 27-Jan-14 5:18am View    
I found the solution myself, I don't use two inkcanvas anymore because I can apply transformations directly on the image...
Thank you anyway.
daphne35 25-Jan-14 10:32am View    
hello,

I put an image that contains a green object on black background in an InkCanvas to be able to draw over. I also apply transformations to Inkvanvas (crushing, translation).

The fact of using a second InkCanvas allows me to draw in the departure area when the InkCanvas has been reduced and still have a black background behind.

I hope my explanation is not too confusing ...

thank you