Advertisement
Guest User

Good luck

a guest
Jul 3rd, 2018
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Public Function Crop(img As Image, Optional mode As Integer = 0, Optional pos As Integer = 1, Optional players As Integer = 0) As Image
  2.         Dim startX As Integer
  3.         Dim startY As Integer
  4.         Dim height As Integer
  5.         Dim width As Integer = 0.4 * img.Height
  6.         Select Case mode
  7.             Case 0
  8.                 startX = (img.Width / 2) - (width * 2)
  9.                 startY = img.Height * 0.457
  10.                 height = img.Height * 0.03
  11.                 width = width * 4
  12.             Case 4
  13.                 startX = (img.Width / 2) - (width * 2) + (width * pos)
  14.                 startY = img.Height * 0.425
  15.                 height = img.Height * 0.03
  16.             Case 3
  17.                 startX = (img.Width / 2) - (1.5 * width) + (width * pos)
  18.                 startY = img.Height * 0.425
  19.                 height = img.Height * 0.03
  20.             Case 2
  21.                 startX = (img.Width / 2) - (width) + (width * pos)
  22.                 startY = img.Height * 0.425
  23.                 height = img.Height * 0.03
  24.             Case 1
  25.                 Select Case players
  26.                     Case 4
  27.                         startX = (img.Width / 2) - (width * 2) + (width * pos)
  28.                         startY = img.Height * 0.4
  29.                         height = img.Height * 0.03
  30.                     Case 3
  31.                         startX = (img.Width / 2) - (1.5 * width) + (width * pos)
  32.                         startY = img.Height * 0.4
  33.                         height = img.Height * 0.03
  34.                     Case 2
  35.                         startX = (img.Width / 2) - (width) + (width * pos)
  36.                         startY = img.Height * 0.4
  37.                         height = img.Height * 0.03
  38.                 End Select
  39.         End Select
  40.         Dim CropRect As New Rectangle(startX, startY, width, height)
  41.         Dim OriginalImage = img
  42.         Dim CropImage = New Bitmap(CropRect.Width, CropRect.Height)
  43.         Using grp = Graphics.FromImage(CropImage)
  44.             grp.DrawImage(OriginalImage, New Rectangle(0, 0, CropRect.Width, CropRect.Height), CropRect, GraphicsUnit.Pixel)
  45.             Return CropImage
  46.         End Using
  47.     End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement