RE: Convert PICT to NSImage (SOLVED)
RE: Convert PICT to NSImage (SOLVED)
- Subject: RE: Convert PICT to NSImage (SOLVED)
- From: Ian was here <email@hidden>
- Date: Tue, 28 Jun 2005 09:32:12 -0700 (PDT)
Thank you to all who helped in this!!
Here is the code for converting a PICT into an NSImage
and attaching it to an NSTextView from memory:
HLock( (Handle)thePict );
NSData *pictData = [NSData dataWithBytes:*thePict
length:GetHandleSize( (Handle)thePict )];
HUnlock( (Handle)thePict );
NSPICTImageRep *pictImageRep = [NSPICTImageRep
imageRepWithData:pictData];
int leftEdge = (**thePict).picFrame.left;
int rightEdge = (**thePict).picFrame.right;
int topEdge = (**thePict).picFrame.top;
int bottomEdge = (**thePict).picFrame.bottom;
NSImage *pictImage = [[NSImage alloc]
initWithSize:NSMakeSize( (float)(rightEdge -
leftEdge), (float)(bottomEdge - topEdge) )];
[pictImage addRepresentation:pictImageRep];
NSTextAttachment *textAttachment = [[NSTextAttachment
alloc] init];
NSTextAttachmentCell *attCell =
[[[NSTextAttachmentCell alloc]
initImageCell:pictImage] autorelease];
[textAttachment setAttachmentCell:attCell];
[[textView textStorage]
appendAttributedString:[NSAttributedString attributedStringWithAttachment:textAttachment]];
____________________________________________________
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