Login  Register

Re: Reading a binary file

Posted by Michael Schmid on Jun 02, 2009; 3:30pm
URL: http://imagej.273.s1.nabble.com/Reading-a-binary-file-tp3692318p3692322.html

On 2 Jun 2009, at 16:20, KB wrote:
> Can you please point me to some documentation about buffered input  
> stream
> you talk about? I did mention I am new to javascript! :)
>


Hava a look at java.sun.com; there you find all java documentation,  
e.g.,

http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html

DataInputStream has the advantage that it reads signed as well as  
unsigned short, but the disadvantage that the overhead of a method  
call for each short makes it significantly slower than methods that  
return arrays.

Your current code extracts bytes from the short data to swap the bytes.
It would be faster to read the bytes for a row of pixels or the whole  
image into an array (InputStream can fill a byte buffer) and then  
compose the shorts from the bytes array.

Michael