Dim debutx = 0 Dim debuty = 0 Dim finx = 150 Dim finy = 150 Dim NbrImage = 0 Dim w1 = (finx - debutx) Dim h1 = (finy - debuty) Dim x As Integer For x = 1 To 4 NbrImage += 1 PictureBox2.Image = RognImage(PictureBox1.Image, debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Next
resultat ça fonctionne
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPublic Class Form1 Dim fichier As String Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) End Sub Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim debutx = 0 Dim debuty = 0 Dim finx = 150 Dim finy = 150 Dim NbrImage = 0 Dim w1 = (finx - debutx) Dim h1 = (finy - debuty) Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx = 600 Then If finy = 600 Then Exit For Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debutx += 150 finx += 150 End If Next End Sub Private Function RognImage(ByVal ImaSource As Bitmap, ByVal xPixelDep As Int32, ByVal yPixelDep As Int32, ByVal xPixelTotal As Int32, ByVal yPixelTotal As Int32) As Bitmap Dim nouvImage As New Bitmap(xPixelTotal, yPixelTotal) Dim graph As Graphics = Graphics.FromImage(nouvImage) Dim rect As New Rectangle(0, 0, xPixelTotal, yPixelTotal) graph.DrawImage(ImaSource, rect, xPixelDep, yPixelDep, xPixelTotal, yPixelTotal, GraphicsUnit.Pixel) Return nouvImage End Function End Class
Public Class Form1 Dim fichier As String Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) End Sub Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim debutx = 0 Dim debuty = 0 Dim finx = 150 Dim finy = 150 Dim NbrImage = 0 Dim w1 = (finx - debutx) Dim h1 = (finy - debuty) Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx = 600 Then If finy = 600 Then Exit For Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debutx += 150 finx += 150 End If PictureBox2.Image.Dispose() Next End Sub Private Function RognImage(ByVal ImaSource As Bitmap, ByVal xPixelDep As Int32, ByVal yPixelDep As Int32, ByVal xPixelTotal As Int32, ByVal yPixelTotal As Int32) As Bitmap Dim nouvImage As New Bitmap(xPixelTotal, yPixelTotal) Dim graph As Graphics = Graphics.FromImage(nouvImage) Dim rect As New Rectangle(0, 0, xPixelTotal, yPixelTotal) graph.DrawImage(ImaSource, rect, xPixelDep, yPixelDep, xPixelTotal, yPixelTotal, GraphicsUnit.Pixel) Return nouvImage End Function End Class
Public Class Form1 Dim fichier As String Dim debutx As Integer = 0 Dim debuty As Integer = 0 Dim finx As Integer = 150 Dim finy As Integer = 150 Dim NbrImage As Integer = 0 Dim w1 As Integer = (finx - debutx) Dim h1 As Integer = (finy - debuty) Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) End Sub Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx 600 And finy 600 Then Exit For Else If finx < 600 Then PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If End If PictureBox2.Image.Dispose() Next End Sub Private Function RognImage(ByVal ImaSource As Bitmap, ByVal xPixelDep As Int32, ByVal yPixelDep As Int32, ByVal xPixelTotal As Int32, ByVal yPixelTotal As Int32) As Bitmap Dim nouvImage As New Bitmap(xPixelTotal, yPixelTotal) Dim graph As Graphics = Graphics.FromImage(nouvImage) Dim rect As New Rectangle(0, 0, xPixelTotal, yPixelTotal) graph.DrawImage(ImaSource, rect, xPixelDep, yPixelDep, xPixelTotal, yPixelTotal, GraphicsUnit.Pixel) Return nouvImage End Function End Class
Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx > 600 And finy > 600 Then Exit For Else If finx < 600 Then PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) PictureBox2.Image.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If End If PictureBox2.Image.Dispose() Next
Public Class Form1 Dim fichier As String Dim debutx As Integer = 0 Dim debuty As Integer = 0 Dim finx As Integer = 150 Dim finy As Integer = 150 Dim NbrImage As Integer = 0 Dim w1 As Integer = (finx - debutx) Dim h1 As Integer = (finy - debuty) Dim nouvImage As Bitmap Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) End Sub Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx > 600 And finy > 600 Then Exit For Else If finx < 600 Then PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) nouvImage.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Else PictureBox2.Image = RognImage(CType(PictureBox1.Image, Bitmap), debutx, debuty, w1, h1) nouvimage.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If End If PictureBox2.Image.Dispose() Next PictureBox2.Dispose() End Sub Private Function RognImage(ByVal ImaSource As Bitmap, ByVal xPixelDep As Int32, ByVal yPixelDep As Int32, ByVal xPixelTotal As Int32, ByVal yPixelTotal As Int32) As Bitmap nouvImage = New Bitmap(xPixelTotal, yPixelTotal) Dim graph As Graphics = Graphics.FromImage(nouvImage) Dim rect As New Rectangle(0, 0, xPixelTotal, yPixelTotal) graph.DrawImage(ImaSource, rect, xPixelDep, yPixelDep, xPixelTotal, yPixelTotal, GraphicsUnit.Pixel) Return nouvImage End Function End Class
Dim firstImg As Bitmap
Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) firstImg = New Bitmap(fichier) End Sub
Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx > 600 And finy > 600 Then Exit For Else If finx < 600 Then PictureBox2.Image = RognImage(firstImg, debutx, debuty, w1, h1) nouvImage.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Else PictureBox2.Image = RognImage(firstImg, debutx, debuty, w1, h1) nouvimage.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If End If PictureBox2.Image.Dispose() Next PictureBox2.Dispose() End Sub
Public Class Form1 Dim fichier As String Dim debutx As Integer = 0 Dim debuty As Integer = 0 Dim finx As Integer = 150 Dim finy As Integer = 150 Dim NbrImage As Integer = 0 Dim w1 As Integer = (finx - debutx) Dim h1 As Integer = (finy - debuty) Dim nouvImage As Bitmap Dim firstImg As Bitmap Dim graph As Graphics Dim rect As Rectangle Private Sub OuvrirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OuvrirToolStripMenuItem.Click OpenFileDialog1.ShowDialog() fichier = OpenFileDialog1.FileName PictureBox1.ImageLocation = CStr(fichier) firstImg = New Bitmap(fichier) End Sub Private Sub EnregistrerSousToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EnregistrerSousToolStripMenuItem.Click Dim x As Integer For x = 1 To 16 NbrImage += 1 If finx > 600 And finy > 600 Then Exit For Else If finx < 600 Then PictureBox2.Image = RognImage(firstImg, debutx, debuty, w1, h1) nouvImage.Save(NbrImage & ".jpg") debutx += 150 finx += 150 Else PictureBox2.Image = RognImage(firstImg, debutx, debuty, w1, h1) nouvimage.Save(NbrImage & ".jpg") debuty += 150 finy += 150 debutx = 0 finx = 150 End If End If PictureBox2.Image.Dispose() Next PictureBox2.Dispose() End Sub Private Function RognImage(ByVal ImaSource As Bitmap, ByVal xPixelDep As Int32, ByVal yPixelDep As Int32, ByVal xPixelTotal As Int32, ByVal yPixelTotal As Int32) As Bitmap nouvImage = New Bitmap(xPixelTotal, yPixelTotal) graph = Graphics.FromImage(nouvImage) rect = New Rectangle(0, 0, xPixelTotal, yPixelTotal) graph.DrawImage(ImaSource, rect, xPixelDep, yPixelDep, xPixelTotal, yPixelTotal, GraphicsUnit.Pixel) Return nouvImage End Function End Class
PictureBox2.Dispose() NbrImage = 0 debutx = 0 debuty = 0 finx = 150 finy = 150
nouvimage = RognImage(firstImg, debutx, debuty, w1, h1) nouvImage.Save(NbrImage.tostring & ".jpg")