On Feb 16, 2007, at 3:16 PM, Peter K. Stys wrote:
On 2/16/07, Charles Yeomans <[EMAIL PROTECTED]> wrote:
The best thing would be to be able to pick a representation, say,
little endian, and use it always. If you have control over reading
and writing of image data, then you should be to do so.
Charles:
this would be easiest, but I suspect not best: if i used say
littleEndian always, then my app running on a bigEndian Mac would
always be forced to either byte-swap a 100 MB file during read/write,
or worse, force the memblocks to byte-swap every m.ushort access
because m would be set to its unnatural littleEndian setting on a
bigEndian machine. Or am I missing something?
I think you're missing something. Let's assume that your image data
is always written out in little endian format. Then when you read it
in using a BinaryStream, set BinaryStream.LittleEndian = true on
either platform, and proceed from there.
Another surprise I just noticed is that a file written on an Intel
Mac, then opened on a PPC Mac, was able to correctly read
binStream.readLong's even tho the byteorder is different on the 2
machines. I suspect because bin streams are always written as
bigendian regardless of platform. My problem arose because I also
directly do:
binStream.Write m.stringValue(0, dataSize)
so this wrote raw data in littleEndian order from the Intel Mac, which
the PPC Mac later assumed was bigEndian. (but all the writeLong's etc
are always bigendian so there is no confusion, the byte swap occurred
when the file is written from an Intel Mac I assume; my issue is that
byte-swapping a 100 MB block would be a huge performance hit). Do I
understand this right?
I wrote a dumb test in which I wrote 1000000 longs to a file in both
little-endian and big-endian format. There was no difference in
execution times on my MacBook.
Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>