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

Home » Public Forums » archive » Re: How to read two-bytes variables from a file saved in Mac?
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: How to read two-bytes variables from a file saved in Mac? [message #24705] Mon, 16 April 2001 11:58 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"Xiong Hu" <xhu@conrad.ece.uiuc.edu> writes:

> Hi! Does somebody know how to read the two-bytes variables from a file saved
> in Macintosh?
>
> I am trying reading the image data in PC platform. The image data saved in
> IPlab in Mac. And I found out the difference of the way the data be saved in
> between PC and Mac. For example, a two- bytes integer will be saved like:
> 0[low byte]1[high byte] in PC platform. But in Mac, it will be saved like:
> 1[high byte]0[low byte].
>
> So in PC when I try to read a file saved in Mac, I need to read byte by byte
> and do transform in the right way to get the right value of each pixel. But
> I think it is not a good way. I wonder if there are any "keywords" or
> "command" can help me solve this problem directly and efficiently.

You are dealing with an issue called "endianness," which refers to how
a particular CPU stores multi-byte values.

You should investigate the SWAP_* keywords to OPEN, one of them should
be able to help you. If you need to selectively swap data (ie some
values are byte-swapped and others are not), then you can investigate
the BYTEORDER function, which is used after reading the data.

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Previous Topic: MBAR
Next Topic: mbar and event handlers

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

Current Time: Wed Oct 08 18:55:44 PDT 2025

Total time taken to generate the page: 0.00403 seconds