• 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: NSImage questions from a newbie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage questions from a newbie


  • Subject: Re: NSImage questions from a newbie
  • From: Brian Webster <email@hidden>
  • Date: Fri, 3 Aug 2001 15:50:07 -0500

On Friday, August 3, 2001, at 11:30 AM, cocoa-dev-
email@hidden wrote:

what i have tried so far:
I told an NSImage to add a pict rep which was initialized with nil as
its data, then i tried to remove the other reps (crash)
I added the PictImageRep and tried to select the pict imagerep for
drawing (which is impossible).

The NSPictImageRep class only has support for drawing existing PICTs, not for creating new ones, so this class probably isn't going to be much help.

I have ripped out someone else's Carbon code that creates a picHandle to
a valid Pict in memory , I then get a new instance of an NSData Object
with dataWithBuffer: sending the handle and its length (as found by
GetHandleSize), next i try to initialize a NSPICTImageRep using that
NSdata Object, again the app crashes.

This sounds like it should have worked, although I don't think that this approach is going to help translate an existing NSImage into a PICT file. There's one thing you might check, though. Are you just passing in the handle to create the NSData, or what the handle points to? See, a Handle is actually a pointer to a pointer, so to get to the data, you'd have to dereference it twice. This is due to the old krusty memory management abilities of the MacOS. So, creating an NSData from the contents of a handle goes like this:

Handle handle;
NSData *data;

data = [NSData dataWithBytes:*handle size:GetHandleSize(handle)];

However, the data that needs to be passed in to make an NSPictImageRep has to be in PICT format, which is what you're trying to get in the first place, so this all isn't too helpful.


I am wondering if there is a way to make use of NSbitmappedImage, but I
am quite fed up with shooting in the dark.
can anybody lay out the path one would take to turn an instance of
NSImage, into a pict file? keep in mind that I would rather steer clear
of carbon at this point unless its Quicktime.

I took a look at the Quicktime graphics import/export docs, and they are pretty formidable. I believe that support for graphics importers was added to NSImage, but not support for graphics exporters, which is what would be needed to use NSImage to create PICT data.

So, it looks like you'll have to deal with either Carbon or Quicktime in order to do this. I don't know much about the Quicktime API, but I did find a sample code on Apple's site that does stuff with graphics exporters at <http://developer.apple.com/samplecode/Sample_Code/QuickTime/Importers_and_Exporters/
QTGraphics.htm>.

--
Brian Webster
email@hidden
http://www.owlnet.rice.edu/~bwebster


  • Prev by Date: Re: "help" URLs
  • Next by Date: Re: "help" URLs
  • Previous by thread: NSImage questions from a newbie
  • Next by thread: [ANN] Vermont Recipes 4 released
  • Index(es):
    • Date
    • Thread