• 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: Getting NSData out of an NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting NSData out of an NSImage


  • Subject: Re: Getting NSData out of an NSImage
  • From: Paul Lynch <email@hidden>
  • Date: Sat, 8 Apr 2006 10:43:19 +0100


On 8 Apr 2006, at 10:13, Paul Lynch wrote:


On 8 Apr 2006, at 00:38, Bobby B wrote:

I have an NSImage that I load from a file.  I load it, and I draw on
it.  Now, I want to take this image and put it into a NSData format,
to store it as a binary attribute in a CoreData program.

I can't seem to figure out how to get an NSData representation of
NSImage. I can do it the other way (get an NSImage from NSData), but
that doesn't help. I looked at NSBitmapImageRep, but that didn't help
because it didn't allow me a way to draw to it like I did in NSImage
(I just used drawAtPoint withAttributes:, I just needed to draw a
string.)

There are many ways of getting an NSData from an image. Look at the NSCoding protocol, or the TIFFRepresentation methods, and the various representations. If you use a representation, then you need to reconstruct the NSImage from the representation, as only NSImage can draw itself. If the image is only used for drawing on screen, then you probably only need one representation.

I could have phrased that better - image reps can draw themselves, of course, but for most situations you are probably better off reconstructing an image anyhow.


Paul

_______________________________________________
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: 
 >Getting NSData out of an NSImage (From: "Bobby B" <email@hidden>)
 >Re: Getting NSData out of an NSImage (From: Paul Lynch <email@hidden>)

  • Prev by Date: Re: NSBitmapImageRep subclass problem (SOLVED)
  • Next by Date: Altering CoreData generated view/controls
  • Previous by thread: Re: Getting NSData out of an NSImage
  • Next by thread: Re: Getting NSData out of an NSImage
  • Index(es):
    • Date
    • Thread