Results 1 to 4 of 4

Thread: Quick Saving

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2012
    Posts
    20

    Quick Saving

    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
    Code:
     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

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Quick Saving

    You're reducing the size of the image but saving a 1024x768 image. The result is a lot of black space around an image the size of your picture box in the top left corner. It is not that the whole saved file is black, there's just a whole lot of empty space there!

    Name:  Lecture1.jpg
Views: 117
Size:  26.2 KB
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2012
    Posts
    20

    Re: Quick Saving

    I solved it :| I just change the image's file extension to .PNG instead of JPG

  4. #4
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,245

    Re: Quick Saving

    Quote Originally Posted by k3nnt0ter0 View Post
    I solved it :| I just change the image's file extension to .PNG instead of JPG
    So now you have a whole lot of white/transparent space instead of black? Well, as long as you're happy, I suppose.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width