• 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: Saving PNG files from NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Saving PNG files from NSImage


  • Subject: Re: Saving PNG files from NSImage
  • From: Martin Linklater <email@hidden>
  • Date: Mon, 29 Aug 2011 16:28:51 +0100

Thanks for the info guys.

The method below is working great.

On 29 Aug 2011, at 14:38, Marco Tabini wrote:

> Hi Martin—
>
> On 2011-08-29, at 9:11 AM, Martin Linklater wrote:
>
>> Thanks Marco. When I call representationUsingType I get this:
>>
>
> You need to first convert the representation to an NSBitmapImageRep, which can then be converted to PNG; for example:
>
> - (NSData *) PNGRepresentationOfImage:(NSImage *) image {
>     // Create a bitmap representation from the current image
>
>     [image lockFocus];
>     NSBitmapImageRep *bitmapRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:NSMakeRect(0, 0, image.size.width, image.size.height)];
>     [image unlockFocus];
>
>     return [bitmapRep representationUsingType:NSPNGFileType properties:Nil];
> }
>
> I wrote a simple app (requires Xcode 4.1 with ARC enabled) for you to try out. You can grab it from here.
>
> Cheers,
>
>
> —Mt.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Saving PNG files from NSImage (From: Martin Linklater <email@hidden>)
 >Re: Saving PNG files from NSImage (From: Marco Tabini <email@hidden>)
 >Re: Saving PNG files from NSImage (From: Martin Linklater <email@hidden>)

  • Prev by Date: Re: Saving PNG files from NSImage
  • Next by Date: Re: Long delay of NSPopUpButton first click
  • Previous by thread: Re: Saving PNG files from NSImage
  • Next by thread: ARC + CF types
  • Index(es):
    • Date
    • Thread