comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Reading binary data whose source code not given
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Reading binary data whose source code not given [message #2081 is a reply to message #2080] Wed, 18 May 1994 09:33 Go to previous message
8015 is currently offline  8015
Messages: 52
Registered: November 1993
Member
In article <2rd8ft$hn2@mojo.eng.umd.edu>,
Rajiv Madabhushi <madabhus@eng.umd.edu> wrote:
>
> I have a binary file with a 400 by 400 array. All I know about the
> elements of that array is that they are written as 16-bit 2's complement
> data. The file was created on a pc. I am no sure about what language
> the software that creates this file is written in (and cannot
> find out :-( ).
>
> I am using IDL version 3.0 on a Sun SPARC 10 workstation. I have tried

Going from the PC to a Sun SPARC you will need to swap the byte order
of the file. You can do this within IDL using the byteorder command
(byteorder, data, /options), or from the Unix command line using the dd
command (dd if=infile of=outfile conv=swab). Correct me if I'm wrong,
but I don't think the 2's complement info comes into play. The
following ought to allow you to get the data to a point where it is
useable.

openr, lun, 'pc_file', /get_lun ; open the file for reading
fvar = fstat(lun) ; optional - in case all your data is not 400x400
arr_size = fix(sqrt(fvar.size)) ; optional - get array size from file size
data = intarr(arr_size, arr_size) ; allocate an array to hold the data
readu, lun, data ; read the file into an array
byteorder, data ; change the byte order of the array
...

Hope that works, or at least gives you a starting point.

Mike Schienle Hughes Santa Barbara Research Center
mgs@sbjse0.sbrc.hac.com 75 Coromar Drive, M/S B28/87
Voice: (805)562-7466 Fax: (805)562-7881 Goleta, CA 93117
[Message index]
 
Read Message
Read Message
Previous Topic: Reading binary data whose source code not given
Next Topic: GIF reader/writer for IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:36:14 PDT 2025

Total time taken to generate the page: 0.64447 seconds