On 2/16/07, Frank Condello <[EMAIL PROTECTED]> wrote:
On 16-Feb-07, at 3:16 PM, Peter K. Stys wrote:
Now, I would still swap the whole block in this situation (or at least the parts that need it) but do it using Ptr.Byte not Memoryblock.ByteValue and you'll see a massive gain. Honestly though, for large blocks like you're describing I'd do this sort of thing in a plugin, which will be faster still. Once your block is swapped for the current platform you can use fast Ptr access all the time without worrying about endianess. You still need to pick an endianess and stick to it for the file format however.
but if I pick a fixed endianness, the huge memblocks will always need to be swapped on one of the platforms when the file is read. If the endianness matches the current platform, then the swap will only be required if the file is opened on the other platform (a far less frequent event). Incidentally, can you change binStream.LittleEndian on-the-fly, while the stream is open? Finally, there are even more subtle issues. I create an RGB image from raw pixel data by calling: sourceMap = GetGWorldPixMap( (GWorldPtr) sourceDes.pictureData); ... sourceData = (long*) GetPixBaseAddr( sourceMap ); // get the base addr of pix data then generate the 32 bit color (8 bits per color channel + alpha): sourceData[sourceLineAddrOffset+xCtr] = (redColor << 16) | (grnColor << 8) | (bluColor); where red/grn/bluColor vary from 0-255 depending on the pixel values. Even tho numerically the pixel values are correct on Intel, the color generated by the last statement is wrong: is that because red/grn/bluColor are shifted into the wrong byte positions because of Intel endianness (this was originally written for PPC)? This could break many plugin operations that perform direct byte-wise access of pointers. Nuts! P.
_______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
-- ------------------------------------------------------------------------------- Peter K. Stys, MD Professor of Medicine(Neurology), Senior Scientist Ottawa Health Research Institute, Div. of Neuroscience Ottawa Hospital / University of Ottawa Ontario, CANADA tel: (613)761-5444 fax: (613)761-5330 http://www.ohri.ca/profiles/stys.asp ------------------------------------------------------------------------------- _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives: <http://support.realsoftware.com/listarchives/lists.html>
