Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public Function Crop(img As Image, Optional mode As Integer = 0, Optional pos As Integer = 1, Optional players As Integer = 0) As Image
- Dim startX As Integer
- Dim startY As Integer
- Dim height As Integer
- Dim width As Integer = 0.4 * img.Height
- Select Case mode
- Case 0
- startX = (img.Width / 2) - (width * 2)
- startY = img.Height * 0.457
- height = img.Height * 0.03
- width = width * 4
- Case 4
- startX = (img.Width / 2) - (width * 2) + (width * pos)
- startY = img.Height * 0.425
- height = img.Height * 0.03
- Case 3
- startX = (img.Width / 2) - (1.5 * width) + (width * pos)
- startY = img.Height * 0.425
- height = img.Height * 0.03
- Case 2
- startX = (img.Width / 2) - (width) + (width * pos)
- startY = img.Height * 0.425
- height = img.Height * 0.03
- Case 1
- Select Case players
- Case 4
- startX = (img.Width / 2) - (width * 2) + (width * pos)
- startY = img.Height * 0.4
- height = img.Height * 0.03
- Case 3
- startX = (img.Width / 2) - (1.5 * width) + (width * pos)
- startY = img.Height * 0.4
- height = img.Height * 0.03
- Case 2
- startX = (img.Width / 2) - (width) + (width * pos)
- startY = img.Height * 0.4
- height = img.Height * 0.03
- End Select
- End Select
- Dim CropRect As New Rectangle(startX, startY, width, height)
- Dim OriginalImage = img
- Dim CropImage = New Bitmap(CropRect.Width, CropRect.Height)
- Using grp = Graphics.FromImage(CropImage)
- grp.DrawImage(OriginalImage, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
- Return CropImage
- End Using
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement