0
可能有一個簡單的答案,但我已經嘗試了很多事情,似乎沒有任何工作,除非我只是手動顯示圖像,但我想要的是對其他圖片使用這個子圖,以後我會修復它以顯示這些圖像。我的代碼如下如何顯示部分使用圖片框陣列的for循環
Private Sub updateStandardToolbar()
'Draws the sprites to the pictureboxes
Dim bit As New Bitmap(gridSize, gridSize)
Dim dest_rect As Rectangle = New Rectangle(0, 0, gridSize, gridSize)
Dim i As Integer = 0
' Associate a Graphics object with the Bitmap
Dim gr As Graphics = Graphics.FromImage(bit)
For y As Integer = 0 To standardNum.Y
For x As Integer = 0 To standardNum.X
Call getSrcRect(x, y)
'Copy that part of the image.
gr.DrawImage(bmpStandardTile, dest_rect, src_rect, GraphicsUnit.Pixel)
'Display the result.
pb(i).Image = bit
i += 1
Next
Next
End Sub
這段代碼的問題是所有的pictureboxes(PB())顯示同樣的畫面是我的形象上的最後一個。 StandardNum.x和standardNum.y分別是保存3和1的變量。 bmpStandardTile是我想要複製的圖像,希望dest_rect和src_rect可以自我解釋=)。任何幫助表示讚賞。