the image is sliced to 121 even pieces as .bmp files
in the code the bitmap.save gdi error is fixed, no problemo .
you can hard code to get another number of slices in your needed size ( height & width wize ).
in the code the bitmap.save gdi error is fixed, no problemo .
you can hard code to get another number of slices in your needed size ( height & width wize ).
Code:
Public Class Form1
Dim bitmap1 As Bitmap
Dim outputPath As String = Nothing
Private Sub btnInput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInput.Click
Try
OpenFileDialog1.ShowDialog()
Label2.Visible = False
Label2.Text = Nothing
Dim fs As IO.FileStream = New IO.FileStream(OpenFileDialog1.FileName, IO.FileMode.Open)
bitmap1 = Image.FromStream(fs)
fs.Close()
PictureBox1.Image = bitmap1
Catch ex As Exception
MsgBox("select an input path picture file")
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
OpenFileDialog1.FileName = Nothing
OpenFileDialog2.FileName = Nothing
End Sub
Private Sub btnOutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOutput.Click
Try
OpenFileDialog2.ShowDialog()
outputPath = OpenFileDialog2.FileName
outputPath = outputPath.Substring(0, outputPath.LastIndexOf("\") + 1)
Label1.Text = outputPath
Dim bmts As New Bitmap(bitmap1.Width \ 11, bitmap1.Height \ 11)
For i = 1 To 11
For j = 1 To 11
For hj = 1 To bitmap1.Height \ 11 - 1 ' y of now picture
For wi = 1 To bitmap1.Width \ 11 - 1 ' x of now picture
bmts.SetPixel(wi, hj, bitmap1.GetPixel(wi + (j - 1) * (bitmap1.Width \ 11), hj + (i - 1) * (bitmap1.Height \ 11))) 'fix
Next
Next
Dim bitmapToSave As New Bitmap(bmts)
bitmapToSave.Save(outputPath & (11 * (j - 1) + i) & ".bmp", Imaging.ImageFormat.Bmp)
Next
Next
Label2.Text = "image slicing completed"
Label2.Visible = True
Catch ex As Exception
MsgBox("have you selected an input picture ? is it standard size ?, have you selected a file in a output directory with no files named 1 - 121.bmp")
End Try
End Sub
End Class