You have to convert your InkCanvas to a bitmap. The following code is quick n dirty.
<Window x:Class="InkCanvas.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 Name="yourinkcanvas">
<Image Source="http://blogs.msdn.com/blogfiles/expression/WindowsLiveWriter/ASmallInkCanvasSample_10388/inkcanvasExample_a6d9403d-4bca-40bb-93ad-6364d537f2c6.png"/>
</InkCanvas>
<Button Content="SAVE" Height="20" VerticalAlignment="Bottom" Click="Button_Click"/>
</Grid>
private void Button_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "savedimage"; // Default file name
dlg.DefaultExt = ".jpg"; // Default file extension
dlg.Filter = "Image (.jpg)|*.jpg"; // Filter files by extension
// Show save file dialog box
Nullable<bool> result = dlg.ShowDialog();
// Process save file dialog box results
if (result == true)
{
// Save document
string filename = dlg.FileName;
//get the dimensions of the ink control
int margin = (int)this.yourinkcanvas.Margin.Left;
int width = (int)this.yourinkcanvas.ActualWidth - margin;
int height = (int)this.yourinkcanvas.ActualHeight - margin;
//render ink to bitmap
RenderTargetBitmap rtb =
new RenderTargetBitmap(width, height, 96d, 96d, PixelFormats.Default);
rtb.Render(yourinkcanvas);
using (FileStream fs = new FileStream(filename, FileMode.Create))
{
BmpBitmapEncoder encoder = new BmpBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
encoder.Save(fs);
}
}
}
To save a particular area use margin, width and height.