bytearray

converting byte array to double - c

Hi, I'm trying to get the numerical (double) value from a byte array of 16 elements, as follows: unsigned char input[16]; double output; ... double a = input[0]; distance = a; for (i=1;i<16;i++){ a = input[i] << 8*i; output += a; } but it does not work. It seems that the temporary variable that contains the result of the lef...

[SOLVED] C# - Bogus data when loading a *.wav file to byte array

I am trying to load a *.wav file to a byte array using C# 3.0 and .NET 3.5 like this: var fs = File.Open(filedialog.FileName, FileMode.Open,FileAccess.Read); long numBytes = new FileInfo(filedialog.FileName).Length; BinaryReader br = new BinaryReader(fs); byte[] bytes = br.ReadBytes((int)numBytes); From byte[58] and to the end...

BLOB data to simple string in DataGridView?

I am using C# & MYSQL to develop a desktop application. In one of my form I have a DataGridView (dgvBookings) and in my database table I have a table tblBookings which contains a field specialization of type BLOB. I am selecting data with following query, SELECT * FROM tblBookings WHERE IsActive=1; and then binding the data with Da...

VB.net Hexadecimal to 8-bit unsigned array

I have a hexadecimal value 07A5953EE7592CE8871EE287F9C0A5FBC2BB43695589D95E76A4A9D37019C8 which I want to convert to a byte array. Is there a built in function in .NET 3.5 that will get the job done or will I need to write a function to loop through each pair in the string and convert it to its 8-bit integer equivalent? ...

C# Ensure no duplicates in byte array

What is the easiest way to ensure there are no duplicates and a byte array is in order, say from a network connection? ...

Getting an in-memory representation of the JPEG rendering of an Image.

Hi, I need to know how to get an array of bytes from a loaded image, in java. BufferedImage seems not to supply any methods that produce an array of bytes, so what do I use? ...

How can I read a byte[] out of the database and convert it to an image?

I have a stored procedure that return a varbinary(max) type data. I want to convert that data into an Image. But I have problems with this line: public Image CargarAvatar(string login) { System.Object[] Args = new System.Object[1]; Args[0] = login; DataTable X = new DataTable(); ...

How to fill a byte array from multiple threads safely?

Is there a way to safely populate a byte array from multiple threads (e.g. first thread fills the first half, the second thread fills the second half using System.arraycopy) without synchronizing on the array itself using Java 6 or 7? The jsr166 related libraries only contain int arrays (AtomicIntegerArray, ParallelIntegerArray). ...

flex core ByteArray Image

var myFile:File = new File("./test.jpg"); var myFileStream1:FileStream = new FileStream(); myFileStream1.open(myFile, FileMode.READ); var byte:ByteArray = new ByteArray(); myFileStream1.readBytes(byte,0,byte.bytesAvailable); myFileStream1.close(); now...

Java: Regex on byte array

I want to do something like a regular expression in Java, but on a byte array instead of a String For example, let's say I want to delete from the array all continuous segments of 0's longer than 3 bytes byte a[] = {1,2,3,0,1,2,3,0,0,0,0,4}; byte r[] = magic(a); System.out.println(r); result {1,2,3,0,1,2,3,4} Is there something th...

C# byte array comparison issue

Hello everyone, I have two byte[] arrays in C#. And I am using VSTS 2008 + C# + .Net 3.0. What is the most efficient way to compare whether the two byte arrays contains the same content for each element? For example, byte array {0x1, 0x2} is the same as {0x1, 0x2}, but byte array {0x1, 0x2} and byte array {0x2, 0x1} are not the same. ...

Converting byte array to string and back again in C#

So here's the deal: I'm trying to open a file (from bytes), convert it to a string so I can mess with some metadata in the header, convert it back to bytes, and save it. The problem I'm running into right now is with this code. When I compare the string that's been converted back and forth (but not otherwise modified) to the original byt...

Help with uploading images to EC2 instance (Flash -> PHP)

I have developed an image uploading application that uses Flash to load an image, resize the image and send the bytearray of the image data to a PHP file that outputs the resized file using the following code - $default_path = '/uploads/temp/'; $filename = $_GET["filename"]; $destination = $default_path . $filename; if(file_put_contents...

VB - How do I read and write a binary file?

How do I read a raw byte array from any file... Dim bytes() as Byte ..and then write that byte array back into a new file? I need it as a byte array to do some processing in between. I'm currently using: To read Dim fInfo As New FileInfo(dataPath) Dim numBytes As Long = fInfo.Length Dim fsAs New FileStream(dataPath, FileMode...

MS VC++ Convert a byte array to a BSTR?

Hi, I have a string that starts out in a .Net application, is encrypted and stored in AD. It's then picked up by a native C++ app and decrypted to produce an array of bytes e.g "ABCDEF" becomes 00,41,00,42,00,43,00,44,00,45 once it has been decrypted at the C++ end. I need to take this byte array and convert it to the BSTR "ABCDEF" so t...

Best way to find position in the Stream where given byte sequence starts

How do you think what is the best way to find position in the System.Stream where given byte sequence starts (first occurence): public static long FindPosition(Stream stream, byte[] byteSequence) { long position = -1; /// ??? return position; } P.S. The simpliest yet fastest solution is preffered. :) ...

How to convert an XmlDocument to an array<byte>?

I constructed an XmlDocument and now I want to convert it to an array. How can this be done? Thanks, ...

How to read a bin file to a byte array?

I have a bin file that I need to convert to a byte array. Can anyone tell me how to do this? Here is what I have so far: File f = new File("notification.bin"); is = new FileInputStream(f); long length = f.length(); /*if (length > Integer.MAX_VALUE) { // File is too large }*/ // Create the byte array to hold the data byte[] byt...

How do I convert an array on the client into a byte[] on the server?

I have a class that encrypts and decrypts a string. It uses rijndael. Anyways, I am trying to store an encrypted value on the client. That works all fine and dandy. My problem is when I want to decrypt the value, I need the Key and IV(InitVector) that was used to encrypt the string. They are byte[] values. I currently output those to the...

Splitting H.264 with ActionScript

Hello All, I'm wondering if someone can help me with references or code snippet of H.264 files splitting. ...