我想填充3“小图像”到1大图像。图像已按顺序设置。 问题是,在这种情况下,该目录包含10个“小图像”。我怎样才能加载10张图片,将它们分成三组,然后保存我的“大图片”并继续显示下三张“小图片”?组目录文件成组VB.Net
更新:2
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim files As String() = Directory.GetFiles("C:\pics\")
For i As Integer = 0 To files.Length - 1 Step 3
Dim file1 As String = Nothing
Dim file2 As String = Nothing
Dim file3 As String = Nothing
file1 = files(i)
If i < files.Length - 1 Then
file2 = files(i + 1)
End If
If i < files.Length - 2 Then
file3 = files(i + 2)
End If
'Here the background is created and filled.
Dim img As New Bitmap(2400, 3000)
Dim img_back As Graphics = Graphics.FromImage(img)
img.SetResolution(300, 300)
img_back.FillRectangle(Brushes.White, 0, 0, 2400, 3000)
' Sets Spot names for ech ticket
Dim Ticket_1 As New Bitmap(file1, True)
Dim Ticket_2 As New Bitmap(file2, True)
Dim Ticket_3 As New Bitmap(file3, True)
'This creates New merged image
Dim g As Graphics = Graphics.FromImage(img)
g.DrawImage(Ticket_1, 500, 200)
g.DrawImage(Ticket_2, 500, 1000)
g.DrawImage(Ticket_3, 500, 1800)
'We Save rendered image and display on picturebox
img.Save("C:\pics\list\" & i & "NewTicket List.jpg")
PictureBox1.Image = img
Next
'PictureBox1.Image.Save("C:\pics\New" + 1)
MsgBox("All Done!")
End Sub
如果数组包含3我得到一个空的错误 我该如何处理这些文件被空基本上让他们为空分割图像的非量?
更新3
避开值是零,我改变
Dim files As String() = Directory.GetFiles("C:\pics\")
For i As Integer = 0 To files.Length - 1 Step 3
Dim file1 As String = Nothing
Dim file2 As String = Nothing
Dim file3 As String = Nothing
file1 = files(i)
If i < files.Length - 1 Then
file2 = files(i + 1)
End If
If i < files.Length - 2 Then
file3 = files(i + 2)
End If
这个
Dim files As String() = Directory.GetFiles("C:\pics\")
For i As Integer = 0 To files.Length - 1 Step 3
Dim file1 As String = "C:\pics\NoImage\NoImage.jpg"
Dim file2 As String = "C:\pics\NoImage\NoImage.jpg"
Dim file3 As String = "C:\pics\NoImage\NoImage.jpg"
file1 = files(i)
If i < files.Length - 1 Then
file2 = files(i + 1)
End If
If i < files.Length - 2 Then
file3 = files(i + 2)
End If
我怎样才能让Ticket_1为空?
有你的问题太多虚假的细节。尽量减少你的问题,只是你需要的具体事情。例如,在这种情况下,你可以简单地说:“我有一个字符串列表,我怎样才能把这个列表分成三组?”字符串是文件路径的事实,并且您将在后面特别对它们做某些事情与手头上的主题无关。 – 2015-04-01 11:36:19