14-08-16, 11:24 PM
يا صبري،
هذه دالة ترجع بالجزء المطلوب من الصورة المرسلة لها مع إحداثايات وحجم الجزء المطلوب اقتطاعه
يمكن تجربة هذه الدالة بوضع PictureBox1 وفيها صورة وPictureBox2 وسوف تظهر فيها الجزء المقتطع
هذه دالة ترجع بالجزء المطلوب من الصورة المرسلة لها مع إحداثايات وحجم الجزء المطلوب اقتطاعه
PHP كود :
Public Function GetCropImage(fromImage As Image, x As Integer, y As Integer, width As Integer, height As Integer) As Image
Dim crpRect As New Rectangle(New Point(x, y), New Size(width, height))
Dim retRect As New Rectangle(0, 0, crpRect.Width, crpRect.Height)
Dim crpImage As New Bitmap(width, height)
Dim g = Graphics.FromImage(crpImage)
g.DrawImage(fromImage, retRect, crpRect, GraphicsUnit.Pixel)
Return crpImage
End Function
يمكن تجربة هذه الدالة بوضع PictureBox1 وفيها صورة وPictureBox2 وسوف تظهر فيها الجزء المقتطع
PHP كود :
Private cropSize As New Size(30, 30)
Private Sub PictureBox1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Me.PictureBox2.Image = GetCropImage(Me.PictureBox1.Image, e.X, e.Y, cropSize.Width, cropSize.Height)
End Sub


