Currently I have a simple application where one button loads an image into an ink canvas as its background; as shown here:
private void Button_Click(object sender, RoutedEventArgs e)
{
Microsoft.Win32.OpenFileDialog openFileDlg = new Microsoft.Win32.OpenFileDialog();
Nullable<bool> result = openFileDlg.ShowDialog();
if (result == true)
{
global.canvas1filepath = openFileDlg.FileName;
System.Windows.Controls.Image myImage = new System.Windows.Controls.Image();
ImageBrush canvas1Background = new ImageBrush();
canvas1Background.ImageSource = new BitmapImage(new Uri(global.canvas1filepath, UriKind.Relative));
inkCanvas1.Background = canvas1Background;
}
}
From here I can draw on the image loaded and then when I press the second button the image will save, this second subroutine is shown below:
private void Button_Click_1(object sender, RoutedEventArgs e)
{
MemoryStream ms = new MemoryStream();
FileStream fs = new FileStream(global.saveLocation, FileMode.Create);
RenderTargetBitmap rtb = new RenderTargetBitmap((int)inkCanvas1.ActualWidth, (int)inkCanvas1.ActualHeight, 96d, 96d, PixelFormats.Default);
rtb.Render(inkCanvas1);
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(rtb));
encoder.Save(fs);
fs.Close();
}
My issue lies in that the image I load in has dimensions of 6000x4000 and when I save the result this is reduced to 350x250. Is there a method of maintaining the size of the image throughout the process?