Quick Saving

k3nnt0ter0

Member
Joined
Aug 21, 2012
Messages
22
Programming Experience
Beginner
I am making a quick save program. . So I have 2 pictureboxes. Upon pressing quick save, the image on the picbox1 will be passed to picbox2. Passing the image is working and it saves also but the image appears black only. It is not saving the image of the picturebox 2...
Here's the code
VB.NET:
 Private Sub btnSS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSS.Click


        Dim cropBitmap As Bitmap
        Dim cropX As Integer
        Dim cropY As Integer
        Dim cropWidth As Integer
        Dim cropHeight As Integer


        Try
            cropX = 0
            cropY = 0
            cropWidth = 1024
            cropHeight = 768
            Dim rect As Rectangle = New Rectangle(cropX, cropY, cropWidth, cropHeight)
            Dim bit As Bitmap = New Bitmap(pbOmni.Image, pbOmni.Width, pbOmni.Height)
            cropBitmap = New Bitmap(cropWidth, cropHeight)
            Dim g As Graphics = Graphics.FromImage(cropBitmap)
            g.DrawImage(bit, 0, 0, rect, GraphicsUnit.Pixel)
            pbSnapShot.Image = cropBitmap
            If Not My.Computer.FileSystem.DirectoryExists("C:\Users\Kenn\Desktop\Screenshot") Then
                My.Computer.FileSystem.CreateDirectory("C:\Users\Kenn\Desktop\Screenshot")
            End If


            Dim strfilename As String
            If Not My.Computer.FileSystem.DirectoryExists("C:\Users\Kenn\Desktop\Screenshot") Then
                My.Computer.FileSystem.CreateDirectory("C:\Users\Kenn\Desktop\Screenshot")
            End If


            Dim counter = My.Computer.FileSystem.GetFiles("C:\Users\Kenn\Desktop\Screenshot")
            Dim intCount As Integer
            intCount = CStr(counter.Count)


            strfilename = "Lecture" & intCount + 1
            pbSnapShot.Image.Save("C:\Users\Kenn\Desktop\Screenshot\" & strfilename & ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
        Catch exc As Exception


            MessageBox.Show(exc.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error)


        End Try
    End Sub
End Class
 
Back
Top