Re: Convert PICT to NSImage
Re: Convert PICT to NSImage
- Subject: Re: Convert PICT to NSImage
- From: Ian was here <email@hidden>
- Date: Mon, 27 Jun 2005 15:12:36 -0700 (PDT)
This is definitely a leap in the right direction.
Thank you! Here's my code thus far:
HLock( (Handle)tempPict );
NSData *theData = [NSData dataWithBytes:*tempPict
length:GetHandleSize( (Handle)tempPict )];
HUnlock( (Handle)tempPict );
NSPICTImageRep *pictImage = [NSPICTImageRep
imageRepWithData:theData];
NSFileWrapper *fileWrapper = [[[NSFileWrapper alloc]
initRegularFileWithContents:theData] autorelease];
NSTextAttachment *textAttachment = [[[NSTextAttachment
alloc] initWithFileWrapper:fileWrapper] autorelease];
[[textView textStorage]
appendAttributedString:[NSAttributedString
attributedStringWithAttachment:textAttachment]];
Still doesn't work though. It would seem that
"theData" is raw PICT data, so it needs to get
transformed by NSPICTImageRep (which it does). The
issue then, is that the correct data needs to be
pulled from the NSPICTImageRep. This is where I'm
stuck, and spinning my wheels. I need to pass an
NSData object containing the correct image data into
fileWrapper object.
--- Douglas Davidson <email@hidden> wrote:
>
> On Jun 27, 2005, at 1:51 PM, Ian was here wrote:
>
> > NSFileWrapper *fileWrapper =
> [[[NSFileWrapper alloc]
> > initWithSerializedRepresentation:theData]
> > autorelease];
> >
> >
>
> You should be using initRegularFileWithContents:
> here. The
> "serialized representation" is a special serialized
> representation of
> an arbitrary file wrapper, potentially including an
> entire directory
> structure. What you have is the contents of a
> single file.
>
> Douglas Davidson
>
>
____________________________________________________
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
http://football.fantasysports.yahoo.com
_______________________________________________
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