|
-
Sep 17th, 2012, 10:24 PM
#1
Thread Starter
Junior Member
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
-
Sep 18th, 2012, 04:16 PM
#2
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!
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!
-
Sep 19th, 2012, 07:23 AM
#3
Thread Starter
Junior Member
Re: Quick Saving
I solved it :| I just change the image's file extension to .PNG instead of JPG
-
Sep 19th, 2012, 08:25 AM
#4
Re: Quick Saving
 Originally Posted by k3nnt0ter0
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|