Append Multiple Arrays Together using VB.Net

Viewed 56

I have a jagged array that contains 40 different arrays. Each one of them has dimensions (250, 250, 2).

I'd like to combine them all into a new array with dimensions (250 * 40, 250 * 40, 2 * 40).

Starting with the first array lbound(jagged) to the last ubound(jagged).

What is a good approach to doing this? I was thinking of simply using loop:

Dim DWG(250 * 40, 250 * 40, 2 * 40) as Double
Dim jagged(40)() as Double = GetArrays(jagged) ' get 40 arrays    
Dim arr(250, 250, 2) as Double

for i = 0 to ubound(jagged)        
    arr = jagged(i)
    for channel = 0 to ubound(arr, 3) 
        for row = 0 to ubound(arr, 1) 
            for column = 0 to ubound(arr, 2) 
                DWG(row + (250 * i), column + ( 250 * i), channel + (2 * i)) = arr(row, column, channel)
            next
        next
    next
next        

I can confirm the above code works. Still seems like there could be a better approach. Just for a little context I'm editing pixel data.

0 Answers
Related