• 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 Adobe Photoshop header, Obj-C
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Reading Adobe Photoshop header, Obj-C


  • Subject: Re: Reading Adobe Photoshop header, Obj-C
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 28 Jun 2011 10:00:51 -0700

On Jun 28, 2011, at 6:23 AM, Kevin Muldoon wrote:

> As you can see from the output, the 'version' & 'reserved' isn't being read at all. Must I coerce/parse something here? Much thanks…

I’m not familiar with the PSD format, but aren’t ‘version’ and ‘reserved’ binary? You’re printing them as C strings.

Assuming ‘version’ is a 16-bit big-endian integer, you could read it like this:

const uint8_t* bytes = [signature bytes];
uint16_t version =  *(const uint16_t*)(bytes + 2);
version = NSSwapBigShortToHost(version);

Another way (that I often use) is to define a C struct that matches the fields and layout of the header, then cast the bytes to a pointer to that struct and read the fields. It makes your code look a lot cleaner, but you have to be careful to (a) make sure the compiler packs the struct fields properly, and (b) you byte-swap all integer/float fields appropriately.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Reading Adobe Photoshop header, Obj-C
      • From: Francis Devereux <email@hidden>
    • Re: Reading Adobe Photoshop header, Obj-C
      • From: Charles Srstka <email@hidden>
    • Re: Reading Adobe Photoshop header, Obj-C
      • From: Kevin Muldoon <email@hidden>
References: 
 >Reading Adobe Photoshop header, Obj-C (From: Kevin Muldoon <email@hidden>)

  • Prev by Date: Re: sorting a pair of arrays
  • Next by Date: Re: sorting a pair of arrays
  • Previous by thread: Reading Adobe Photoshop header, Obj-C
  • Next by thread: Re: Reading Adobe Photoshop header, Obj-C
  • Index(es):
    • Date
    • Thread