Hello all,
i have a picturebox control where the user can draw something. There is a save button which should save the image drawn in the picturebox. This is the code for the save button. I am using common dialog box and using save dialog box available from it. Also, i have used the SavePicture method just like Loadpicture method. But i am getting runtime error...
I posted this in a thread a few days ago, thought it was the same one.
Just save and convert!
Code:
Option Explicit
' NOTE: You must save the file in .BMP format before converting it.
Private Declare Function BmpToJpeg Lib "Bmp2Jpeg.dll" (ByVal BmpFilename As String, ByVal JpegFilename As String, ByVal CompressQuality As Integer) As Integer
Private Sub cmdLoad_Click()
Dim filename As String
On Error Resume Next
'Set the filter to bitmap pictures
dlg.Filter = "Bitmap Files | *.bmp"
dlg.filename = ""
dlg.ShowOpen
'Get the file name
filename = dlg.filename
'Load the picture
picMain.Picture = LoadPicture(filename)
End Sub
'For saving into jpg format you must have
'the Bmp2Jpeg.dll file in your windows folder
Private Sub cmdSave_Click()
Dim filename As String
On Error Resume Next
'Set the filter to JPEG files
dlg.Filter = "JPEG files | *.jpg"
dlg.filename = ""
dlg.ShowOpen
'Get the file name without the ".jpg"
filename = Left(dlg.filename, Len(dlg.filename) - 4)
'Saving the file as Bitmap
SavePicture picMain.Picture, filename & ".bmp"
'Change the bitmap file to the jpg file with the Bmp2Jpg.dll
'100 is the Compress Quality
BmpToJpeg filename & ".bmp", filename & ".jpg", 100
'Deleting the bitmap file
Kill filename & ".bmp"
End Sub
I've included the .dll so you don't have to hunt it down.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.