1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Dim img As New Bitmap(FilePath)
Dim one_img_h As Integer = img.Height / NumericUpDown1.Value
Dim one_img_w As Integer = img.Width / NumericUpDown2.Value
For i As Integer = 0 To NumericUpDown1.Value - 1
For j As Integer = 0 To NumericUpDown2.Value - 1
imgarray(i, j) = New Bitmap(one_img_w, one_img_h)
Dim graphics As Graphics = graphics.FromImage(imgarray(i, j))
graphics.DrawImage(img, New Rectangle(0, 0, one_img_w, one_img_h), New Rectangle(j * one_img_w, i * one_img_h, one_img_w, one_img_h), GraphicsUnit.Pixel)
graphics.Dispose()
Next
Next
For i As Integer = 0 To CInt(NumericUpDown1.Value) - 1
For j As Integer = 0 To CInt(NumericUpDown2.Value) - 1
imgarray(i, j).Save(Path.Combine(folder.SelectedPath, "SplitImage-" & CInt(i) & "-" & CInt(j) & ".png"), ImageFormat.Png)
Next
Next |
Partager