Re: Reading .BMPs the hard way
Re: Reading .BMPs the hard way
- Subject: Re: Reading .BMPs the hard way
- From: "Sean McBride" <email@hidden>
- Date: Fri, 18 Mar 2005 11:39:43 -0500
- Organization: Rogue Research
On 2005-03-18 11:14, Heinrich Giesen said:
>> Still, the values I get back don't seem to be right... Any clues??
>
>You have to respect that all values in a BMP file are littleEndian
>values. So you have to read with something like:
>
>- (int) readIntFrom:(int)inx // byteOrder==NS_LittleEndian
>{
> return (imgDataBuffer[inx+3]<<24) | (imgDataBuffer[inx+2]<<16) |
>(imgDataBuffer[inx+1]<<8) | imgDataBuffer[inx];
>}
Foundation/NSByteOrder.h has some useful functions for this. If you use
NSSwapLittleIntToHost() your code will convert from little endian to
whatever endianness the machine you're building for is.
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden