Re: Question about 2D VB arrays
- From: "Michael C" <nospam@xxxxxxxxxx>
- Date: Tue, 7 Nov 2006 12:03:32 +1100
"John" <John@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E3A15305-8A1A-447B-9EDB-312AB860A8A4@xxxxxxxxxxxxxxxx
Michael,
You state that the following is a 1D array and not a 2D array, this all
lies
in your
perspective
I guess it does.
LONG i, j, k = 0;
LONG* larray = new LONG[480* 640];
for (i=0; i<480; i++) { // loop for rows
for (j=0; j<640; j++) { // loop for columns
larray[i * 640 + j] = k; // row * columns + column
}
}
delete [] larray;
This code could just as easily and efficiently be written
LONG i, j, k = 0;
LONG* larray = new LONG[640 * 480];
for (i=0; i<480; i++) { // loop for rows
for (j=0; j<640; j++) { // loop for columns
larray[j + i * 640] = k; // column row * columns
}
}
delete [] larray;
and be in line with the way c# creates 2D arrays. Doesn't seem like anything
is back to front then :-)
And on a side note, the reason I am using a 480 row 640 column array has
nothing
to do with the screen. I use these dimensions with respect to a CCD
detector
that has 640 columns x 480 rows with each element being a pixel.
I'm sure that CCD is 640x480 to be match screens at the time. But that is
beside the point. Surely the CCD sensor is considered to be a 640x480
sensor.
And you snipped the last point in my previous post that underneath the
storage of the data in c# will be the same as your previous example, just
that they've now got the x and y the right way around.
Michael
.
- References:
- Re: Question about 2D VB arrays
- From: John
- Re: Question about 2D VB arrays
- Prev by Date: Re: VB6 refactoring
- Next by Date: Re: VB Form System CLose Button
- Previous by thread: Re: Question about 2D VB arrays
- Next by thread: Re: Question about 2D VB arrays
- Index(es):