On Feb 16, 2007, at 2:21 PM, Peter K. Stys wrote:
On 2/16/07, Theodore H. Smith <[EMAIL PROTECTED]> wrote:
> My data have nothing to do with strings - it's all raw binary image
> data, so UTF-8 etc. does not enter into the equation.
Aha. So this is a different problem then because your file format is
probably always supposed to be in big endian?
I say... just make a byte swap function. It's really easy. Then make
a function that will swap the bytes upon read, but only if the
platform is correct.
function SwapImageBytes(mb as memoryblock)
#if TargetBigEndian = false then
dim i, char, n as integer
n = mb.size - 1
for i = 0 to n step 2
char = mb.bytevalue(i)
mb.bytevalue(i) = mb.bytevalue(i+1)
mb.bytevalue(i+1) = char
next
#endif
end function
there you go :)
This is cool, because then you can do all your processing without
setting .littleendian to true, which is to be honest, a slow thing to
do.
This is nifty: so do I understand that TargetBigEndian will be
different depending on whether the compiler is building the PPC code
or Intel code DURING a combined UB build?
The other issue is that my data are big (50-100 MB images easily,
often close to a gig). I worry that forcing a byte-swap every time
for a bigendian machine (during the read, AND the write leg too!) as
your code implies will exact a huge performance hit on bigendian
machines.
Would it be reasonable to write non-swapped littlendian files from
littelendian machines (th.f. no swapping required during subsequent
file reads), and writing bigendian files from bigendian machines, then
only force a byte-swap if a file from a littlendian Mac happens to be
opened on a bigendian Mac? The same image file will be different
byte-for-byte on Intel vs. PPC Macs but if I keep track of this, who
cares.
How do the big commercial apps handle this cross-platform issue?
Sorry to be harping on this but if I make the wrong design decision
now I'll regret it later.
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 Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>