interger array to byte array

H

Herfried K. Wagner [MVP]

Nils Wolf said:
how do i convert an integer array to a byte array??

One integer to four bytes or each integer to a single byte (if possible...)?
 
D

David Browne

Nils Wolf said:
hi,

how do i convert an integer array to a byte array??

Hey,

Dim i(300, 300) As Integer
i(0, 0) = 2
Dim bytes As Integer = Buffer.ByteLength(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCopy(i, 0, b, 0, bytes)


David
 
N

Nils Wolf

ok...

thanks again :)

Nils

David Browne said:
Hey,

Dim i(300, 300) As Integer
i(0, 0) = 2
Dim bytes As Integer = Buffer.ByteLength(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCopy(i, 0, b, 0, bytes)


David
 
N

Nils Wolf

ok, i have another problem with this.

the conversion from the int array to byte works fine.
but i have problems with the conversion back from the byte to the int.

when i have the byte array how do i get the original dimensions of the array
i converted to the byte array or is this not possible?

example:

i(1,1) --> i.getlength(0) --> 16
i(2,1) --> i.getlength(0) --> 24
i(1,2) --> i.getlength(0) --> is also 24
 
N

Nils Wolf

ok, i have another problem with this.

the conversion from the int array to byte works fine.
but i have problems with the conversion back from the byte to the int.

when i have the byte array how do i get the original dimensions of the int
array (i dont know them because the byte array comes from the DB)
i converted to the byte array or is this not possible?

example:

i(1,1) --> i.getlength(0) --> 16
i(2,1) --> i.getlength(0) --> 24
i(1,2) --> i.getlength(0) --> is also 24
 
D

David Browne

Nils Wolf said:
ok, i have another problem with this.

the conversion from the int array to byte works fine.
but i have problems with the conversion back from the byte to the int.

when i have the byte array how do i get the original dimensions of the
array i converted to the byte array or is this not possible?

example:

i(1,1) --> i.getlength(0) --> 16
i(2,1) --> i.getlength(0) --> 24
i(1,2) --> i.getlength(0) --> is also 24

If the arryas aren't square, you will need to store the dimensions.

EG

CREATE TABLE 2D_ARRAY_STORAGE
(
ID INT IDENTITY PRIMARY KEY,
X INT NOT NULL,
Y INT NOT NULL,
BITS IMAGE
)

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top