bytearray

Should I use Base64 encoding or byte[] for returning binary data in .NET web service

I have a simple question. Should I return a byte-array or simply base64 encode my binary data, when exposing it through a web service in .NET? Is there any pros/cons with either method, which is mostly supported etc. ...

Is there a less painful way to GetBytes for a buffer not starting at 0?

I am having to deal with raw bytes in a project and I need to basically do something like this byte[] ToBytes(){ byte[] buffer=new byte[somelength]; byte[] tmp; tmp=BitConverter.GetBytes(SomeShort); buffer[0]=tmp[0]; buffer[1]=tmp[1]; tmp=BitConverter.GetBytes(SomeOtherShort); buffer[2]=tmp[0]; buffer[3]=tmp[1]; } I fe...

Remove First 16 Bytes?

How would I go about removing a number of bytes from a byte array? ...

Failed sending bytes array to JAX-WS web service on Axis

Hi I have made a small example to show my problem. Here is my web-service: package service; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public class BytesService { @WebMethod public String redirectString(String string){ return string+" - is what you sended"; } @WebMethod public byte[] redirectBytes(by...

Creating Bitmaps from ARGB strings (in actionscript-3)???

Hi, in actionscript 3, what's the fastest way to dump your data (not from a file) into a bitmap for display? I have it working with setPixels and colored rects but that's way too slow/inefficient. Is there a way to load in the raw bytes or hijack the loader class to put in custom loader data? What would be the best/fastest--should I s...

Having trouble with extension methods for byte arrays

I'm working with a device that sends back an image, and when I request an image, there is some undocumented information that comes before the image data. I was only able to realize this by looking through the binary data and identifying the image header information inside. I originally had a normal method and converted it to an extensi...

Convert a image to a monochrome byte array

I am writing a library to interface C# with the EPL2 printer language. One feature I would like to try to implement is printing images, the specification doc says p1 = Width of graphic Width of graphic in bytes. Eight (8) dots = one (1) byte of data. p2 = Length of graphic Length of graphic in dots (or print lines) Data =...

Write string to fixed-length byte array in C#

somehow couldn't find this with a google search, but I feel like it has to be simple...I need to convert a string to a fixed-length byte array, e.g. write "asdf" to a byte[20] array. the data is being sent over the network to a c++ app that expects a fixed-length field, and it works fine if I use a BinaryWriter and write the characters o...

AS3 computeSpectrum fft true

I am just trying to understand what the values sent back from computeSpectrum(bytes,true,0) mean. I have values ranging from 0 to 1 for each float i read from the byte array but does each value represent a range of Hz Thanks! ...

Filling a byte array in Java

Hey all! For part of a project I'm working on I am implementing a RTPpacket where I have to fill the header array of byte with RTP header fields. //size of the RTP header: static int HEADER_SIZE = 12; // bytes //Fields that compose the RTP header public int Version; // 2 bits public int Padding; // 1 bit public int Extensi...

C#: Convert Byte array into a float

I have a 4 byte array byte[] source = new byte[4]; Now I wanted to convert this source into a 4-byte float value... Can anyone tell me how to do this... ...

Convert in-memory pdf to byte[]

I'm writing a websercive in C# that will generate pdf-files and send back to the caller as a byte[]. The pdf file is generated using a third party component, but I'm struggling with the conversion. The pdf is just an in-memory object in the web service, and I can't find any good way of converting the generated pdf to a byte[] before retu...

Byte array serialization in JSON.NET

Given this simple class: class HasBytes { public byte[] Bytes { get; set; } } I can put it through JSON.NET such that the byte array is base-64 encoded: var bytes = new HasBytes { Bytes = new byte[] { 1, 2, 3, 4 } }; var json = JsonConvert.SerializeObject(bytes); Then I can read it back again in this slightly over-complicated w...

Is there a simpler way to convert a byte array to a 2-byte-size hexadecimal string?

Is there a simpler way of implement this? Or a implemented method in JDK or other lib? /** * Convert a byte array to 2-byte-size hexadecimal String. */ public static String to2DigitsHex(byte[] bytes) { String hexData = ""; for (int i = 0; i < bytes.length; i++) { int intV = bytes[i] & 0xFF; // positive int String hexV = Intege...

Is this the best way to convert String hex to bytes?

Is this the best way to convert String hex to bytes? Or can you think a shorter/simpler? public static byte[] hexToBytes(String hex) { return hexToBytes(hex.toCharArray()); } public static byte[] hexToBytes(char[] hex) { int length = hex.length / 2; byte[] raw = new byte[length]; for (int i = 0; i < length; i++) { int high = Charac...

Convert 2 bytes to a number

I have a control that has a byte array in it. Every now and then there are two bytes that tell me some info about number of future items in the array. So as an example I could have: ... ... Item [4] = 7 Item [5] = 0 ... ... The value of this is clearly 7. But what about this? ... ... Item [4] = 0 Item [5] = 7 ... ... Any idea on...

Convert byte array to wav file

I'm trying to play a wav sound that stored in byte array called bytes. I know that I should convert the byte array to wav file and save it in my local drive then called the saved file but I was not able to convert the byte array to wav file. please help me to give sample code to convert byte arrary of wav sound to wav file. here is my ...

Converting ByteArrayInputStream to xml file

I have an xml document that was serialized into a byte stream and persisted to a database. I any get the byte stream back, but how do I convert it into an xml file again? ...

How do you convert an int to a byte in Objective-C?

Hello, I have an int value which needs to be converted into a byte array. How do you go about doing this in Objective-C? Are there methods to do this? Thank you, ...

Java File and ByteArray or InputStream - please quick help

I want to use jFuge to play some MIDI music in an applet. There's a class for the MIDI pattern - Pattern - and the only method to load the pattern is from a File. Now, I don't know how applets load files and what not, but I am using a framework (PulpCore) that makes loading assets a simple task. If I need to grab an asset from a ZIP cata...