• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Reading .BMPs the hard way
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading .BMPs the hard way


  • Subject: Re: Reading .BMPs the hard way
  • From: Heinrich Giesen <email@hidden>
  • Date: Fri, 18 Mar 2005 11:14:40 +0100


On 18.03.2005, at 06:11, <x-tad-smaller>Alexander Griekspoor</x-tad-smaller> wrote:

<x-tad-smaller>As the current cocoa implementations automatically convert lut-colored,
indexed BMP files to RGB, I am trying to read the files directly and </x-tad-smaller>
. . . . .
<x-tad-smaller>Still, the values I get back don't seem to be right... Any clues??</x-tad-smaller>

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[inx24) | (imgDataBuffer[inx16) | (imgDataBuffer[inx8) | imgDataBuffer[inx];
}


- (int) readShortFrom:(int)inx // byteOrder==NS_LittleEndian
{
return (imgDataBuffer[inx8) | imgDataBuffer[inx];
}

with
unsigned char *imgDataBuffer = (unsigned char *)[<x-tad-smaller>imgdata bytes</x-tad-smaller>];

Excerpt from my BMP reading class: (I used direct addresses instead of structs)

hdrSize = [self readIntFrom:0x0e];
xPelsPerMeter = [self readIntFrom:0x26];
yPelsPerMeter = [self readIntFrom:0x2a];

--
Heinrich Giesen

email: email@hidden


 _______________________________________________
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

  • Follow-Ups:
    • Re: Reading .BMPs the hard way
      • From: "Sean McBride" <email@hidden>
    • Re: Reading .BMPs the hard way
      • From: Scott Ribe <email@hidden>
  • Prev by Date: Re: returnCode from beginSheetModalForWindow is incorrect?
  • Next by Date: Need serious help with NSOutlineView
  • Previous by thread: Re: Reading .BMPs the hard way
  • Next by thread: Re: Reading .BMPs the hard way
  • Index(es):
    • Date
    • Thread