473,786 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

interger array to byte array

hi,

how do i convert an integer array to a byte array??
Nov 21 '05 #1
6 1733
"Nils Wolf" <ni***@gmx.at > schrieb:
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...)?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

"Nils Wolf" <ni***@gmx.at > wrote in message
news:ub******** ******@TK2MSFTN GP15.phx.gbl...
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.ByteLeng th(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCop y(i, 0, b, 0, bytes)
David
Nov 21 '05 #3
ok...

thanks again :)

Nils

"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> schrieb im
Newsbeitrag news:u4******** ******@TK2MSFTN GP09.phx.gbl...

"Nils Wolf" <ni***@gmx.at > wrote in message
news:ub******** ******@TK2MSFTN GP15.phx.gbl...
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.ByteLeng th(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCop y(i, 0, b, 0, bytes)
David


Nov 21 '05 #4
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


"Nils Wolf" <ni***@gmx.at > schrieb im Newsbeitrag
news:e%******** ********@TK2MSF TNGP14.phx.gbl. ..
ok...

thanks again :)

Nils

"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> schrieb im
Newsbeitrag news:u4******** ******@TK2MSFTN GP09.phx.gbl...

"Nils Wolf" <ni***@gmx.at > wrote in message
news:ub******** ******@TK2MSFTN GP15.phx.gbl...
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.ByteLeng th(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCop y(i, 0, b, 0, bytes)
David


Nov 21 '05 #5
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
"David Browne" <davidbaxterbro wne no potted me**@hotmail.co m> schrieb im
Newsbeitrag news:u4******** ******@TK2MSFTN GP09.phx.gbl...

"Nils Wolf" <ni***@gmx.at > wrote in message
news:ub******** ******@TK2MSFTN GP15.phx.gbl...
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.ByteLeng th(i)
Dim b(bytes - 1) As Byte
Buffer.BlockCop y(i, 0, b, 0, bytes)
David


Nov 21 '05 #6

"Nils Wolf" <ni***@gmx.at > wrote in message
news:uW******** ******@tk2msftn gp13.phx.gbl...
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_STORAG E
(
ID INT IDENTITY PRIMARY KEY,
X INT NOT NULL,
Y INT NOT NULL,
BITS IMAGE
)

David
Nov 21 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
14139
by: Ekim | last post by:
hello, I'm allocating a byte-Array in C# with byte byteArray = new byte; Now I want to pass this byte-Array to a managed C++-function by reference, so that I'm able to change the content of the byteArray and afterwards see the changes in C#. (if you wanna know more details: the goal is to write the content of an existing char-array in c++ precisely into the passed byteArray, so that after the function has proceded the content of the...
15
34609
by: Kueishiong Tu | last post by:
How do I convert a Byte array (unsigned char managed) to a char array(unmanaged) with wide character taken into account?
8
10719
by: intrepid_dw | last post by:
Hello, all. I've created a C# dll that contains, among other things, two functions dealing with byte arrays. The first is a function that returns a byte array, and the other is intended to receive a byte array as one of its parameters. The project is marked for COM interop, and that all proceeds normally. When I reference the type library in the VB6 project, and write the code to call the function that returns the byte array, it works
5
9842
by: Robin Tucker | last post by:
I need to marshal an IntPtr (which I've got from GlobalLock of an HGLOBAL) into a byte array. I know the size of the array required and I've got a pointer to the blob, but I can't see how to copy the memory across. Using Marshal.PtrStructure doesn't work - it says my byte() array is not blittable! (byte is a blittable type however). Cannot use Marshal.Copy, because that works the other way around (for mashalling to COM, not from it). ...
1
4202
by: elziko | last post by:
My intention is to store an array of singles inside a DataTable so that it can me peristed somehow, maybe XML file, maybe Access/SQL Server I don't know yet so I'm just saving it as an XML file for testing. Here are my two procedures for saving the array and loading it abck in again. Private Sub Save 'create memory stream and formatter Dim msStorage As MemoryStream = New MemoryStream Dim fStorage As IFormatter = New BinaryFormatter
17
7255
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hi Gurus, I need to transfer a jagged array of byte by reference to unmanaged function, The unmanaged code should changed the values of the array, and when the unmanaged function returns I need to show the array data to the end user. Can I do that? How?
40
36495
by: KG | last post by:
Could any one tell me how to reverse the bits in an interger?
10
6382
by: Scott Townsend | last post by:
So I need to talk to a devices that expects all of the bits and bytes I sent it to be in specific places (not yet 100% defined). I wanted to create a structure/class with all of the data in it and then convert that to a byte array, pass it to the device, then get a reply and then convert that to a structure. I'm having issues with making sure what I've coded is correct. Cant figure out how to define an array in structure that is a...
3
3021
by: susheela s | last post by:
Hi. Hers im subtracting two 16bit numbers by using two 8bit num array.In case if first byte of array is less than first byte of second array den i hav to take borrow form second byte of first array.This i could do ..wat my doubt s suppose if i take 4 elements in array and first byte of first array is less than first byte of second array den im gonna take borrow from second byte of first array,if that second byte of first array is 0 den how can...
0
9497
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.