• 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: Convert PICT to NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert PICT to NSImage


  • Subject: Re: Convert PICT to NSImage
  • From: Greg Titus <email@hidden>
  • Date: Mon, 27 Jun 2005 12:11:26 -0700


On Jun 27, 2005, at 10:38 AM, Ian was here wrote:
I'm getting PICT data from an apple event. There is an
application called Equation Editor that allows for
creating math equations and formulas. When quitting,
Equation Editor converts the equations into a single
PICT file and sends it as an apple event. My
application gets this PICT data. I confirmed that I'm
getting data, and this works fine with an OS 9 version
of my application. So I know I'm getting a PICT file.
The following code seems to work OK:

[NSData dataWithBytes:Pict length:GetHandleSize(
(Handle)Pict )]

It's the NSPICTImageRep imageRepWithData: that is
failing.

Also, dragging an equation onto my text view from
Equation Editor works fine.

Hey Ian,

The problem is - I bet - that the in-memory format of a PICT image is different from the on-disk format of a PICT image. Probably NSPICTImageRep is expecting the latter, and you are giving it the former. When a PICT is saved, it has a 512 byte header stuck on the front for historical reasons, whose content is completely ignored. Try:

NSMutableData *result = [NSMutableData data];
NSData *data = [NSData dataWithBytes:Pict length:GetHandleSize((Handle)Pict )];
[result setLength:512]; // blank 512 byte header for PICT file saved to filesystem
[result appendData:data];


And then feed the "result" data into NSPICTImageRep.

Hope this helps,
	- Greg

_______________________________________________
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


References: 
 >Re: Convert PICT to NSImage (From: Ian was here <email@hidden>)

  • Prev by Date: Re: Why add a nil item to an NSArray ?
  • Next by Date: Re: Check Undefined Function Calls
  • Previous by thread: Re: Convert PICT to NSImage
  • Next by thread: Re: Convert PICT to NSImage
  • Index(es):
    • Date
    • Thread