try using a Save File Dialog
Here is an example code i used in my class "add signature" in vb.net
upon button click a savefile dialog box will appear, after putting a file name and pressing save, it will be save as a png image(i used pngBitmap Encoder)
This has same format with what you are using but with a save file dialog added.
btw. WPFControl.Inkcanvas1 is my inkcanvas
'buttonSaveAsClick
'open save file dialog box
Dim sfd As New SaveFileDialog()
sfd.Filter = "Png Files(*.png)|*.png"
'save file as png (render bitmap and convert/save to png)
Dim result As Nullable(Of Boolean) = sfd.ShowDialog()
Dim fileName As String = ""
If result = True Then
fileName = sfd.FileName
Dim size As Size = New Point(750, 400) '= WPFControl.InkCanvas1.RenderSize
Console.WriteLine(WPFControl.InkCanvas1.RenderSize)
Dim rtb As New RenderTargetBitmap(CInt(size.Width), CInt(size.Height), 96, 96, Windows.Media.PixelFormats.Pbgra32)
rtb.Render(WPFControl.InkCanvas1)
Dim png As New PngBitmapEncoder()
png.Frames.Add(BitmapFrame.Create(rtb))
If String.IsNullOrEmpty(fileName) = True Then
MsgBox("Please Enter a File Name", MsgBoxStyle.Exclamation, "File Name required!")
Exit Sub
Else
Console.WriteLine(sfd.FileName)
Console.WriteLine(convertImage.ConvertImageFiletoBytes(sfd.FileName))
End If
Using stm As Stream = File.Create(fileName)
png.Save(stm)
End Using
End If
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…