• 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 (SOLVED)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Convert PICT to NSImage (SOLVED)
      • From: "Sean McBride" <email@hidden>
    • Re: Convert PICT to NSImage (SOLVED)
      • From: Douglas Davidson <email@hidden>
  • Prev by Date: Re: Spotlight bindings example?
  • Next by Date: Re: Spotlight and API Docs
  • Previous by thread: Re: Fake NSView dimensions for fake printing
  • Next by thread: Re: Convert PICT to NSImage (SOLVED)
  • Index(es):
    • Date
    • Thread