Bu derste ekranda görüntü çekme programını yapacağız
Visual basicte bir tane forum açın ve aşağıdaki nesneleri foruma ekleyin
Formumuza 2 adet buton, 1 adet Picture Box ekleyelim.
Form Load Kodu:
MyBase.Load
Buton1, click olayına aşağıdaki kodları yazınız: ( çek Kodu )
Dim bounds As Rectangle
Dim screenshot As System.Drawing.Bitmap
Dim graph As Graphics
bounds = Screen.PrimaryScreen.Bounds
screenshot = New System.Drawing.Bitmap(bounds.Width, bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
graph = Graphics.FromImage(screenshot)
graph.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy)
PictureBox1.Image = screenshot
Buton 2,click olayına aşağıdaki kodu yazınız (kaydet kodu)
Dim savefiledialog1 As New SaveFileDialog
Try
savefiledialog1.Title = "Save File"
savefiledialog1.FileName = "*.bmp"
savefiledialog1.Filter = "Bitmap |*.bmp"
If savefiledialog1.ShowDialog() = DialogResult.OK Then
PictureBox1.Image.Save(savefiledialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp)
End If
Catch ex As Exception
End Try
ads
Hiç yorum yok: