I have Parent and Child Form
I have a button to save on the child form, which uses the code below, all works fine.
Which then uses code below, located in my GDIPlusLib class:Code:Private Sub menuItemSaveAs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Gdip.SaveDIBAs(Me.Text, bmpptr, pixptr) End Sub
GDIPlusLib
I want to be able to save from the parent form, but if I use:Code:Public Shared Function SaveDIBAs(ByVal picname As String, ByVal bminfo As IntPtr, ByVal pixdat As IntPtr) As Boolean Dim sd As SaveFileDialog = New SaveFileDialog() sd.FileName = picname sd.Title = "Save bitmap as..." sd.Filter = "Bitmap file (*.bmp)|*.bmp|TIFF file (*.tif)|*.tif|JPEG file (*.jpg)|*.jpg|PNG file (*.png)|*.png|GIF file (*.gif)|*.gif|All files (*.*)|*.*" sd.FilterIndex = 1 If sd.ShowDialog() <> DialogResult.OK Then Return False End If Dim clsid As Guid If Not GetCodecClsid(sd.FileName, clsid) Then MessageBox.Show("Unknown picture format for extension " + Path.GetExtension(sd.FileName), "Image Codec", MessageBoxButtons.OK, MessageBoxIcon.Information) Return False End If Dim img As IntPtr = IntPtr.Zero Dim st As Integer = GdipCreateBitmapFromGdiDib(bminfo, pixdat, img) If (st <> 0) Or (Equals(img, IntPtr.Zero)) Then Return False End If st = GdipSaveImageToFile(img, sd.FileName, clsid, IntPtr.Zero) GdipDisposeImage(img) Return st = 0 End Function End Class
Nothing happens, can anyone help?Code:Private Sub menuItemSaveAs_Click(ByVal sender As Object, ByVal e As System.EventArgs) Gdip.SaveDIBAs(Me.Text, bmpptr, pixptr) End Sub
Basically the scanned image appears as an image in the child form.




Reply With Quote