• 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: Writing NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Writing NSImage


  • Subject: Re: Writing NSImage
  • From: Graham Cox <email@hidden>
  • Date: Wed, 21 Jun 2017 20:59:46 +1000

Drop down one level - create a bitmap image rep of the type you want, make a
context for it, draw the image into that, then (if necessary) add it to a
NSImage with addRepresentation:

Working at this level you have total control, and rarely need an NSImage at all.

—Graham




> On 21 Jun 2017, at 4:10 pm, Gerriet M. Denkmann <email@hidden> wrote:
>
> macOS 12.5
>
> I create an image like:
>
> NSImage *subImage = [ [NSImage alloc] initWithSize: subRect.size ];
> [ subImage lockFocus ];
> [ self.image  drawAtPoint:    NSMakePoint(0, 0)
>                               fromRect:               subRect
>                               operation:
> NSCompositingOperationCopy
>                               fraction:               1
> ];
> [ subImage unlockFocus ];
>
> My NSImageView has no problem showing subImage. So far so good.
>
> But now I try to write it like:
> NSArray *representations = subImage.representations;  //      contains 1 rep
> NSBitmapImageRep *oneRep = representations.firstObject;
>
> The problem is: oneRep is an NSCGImageSnapshotRep, which does NOT understand
>       [ NSBitmapImageRep  representationUsingType:properties: ].
> (It crashes with a message to this effect).
>
> So: how can I provide my subImage with a nice and valid NSBitmapImageRep?
>
> Btw.: subImage.TIFFRepresentation does work, but I am not really interested
> in Tiff.
>
> Gerriet.
>
> _______________________________________________
>
> 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

_______________________________________________

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: 
 >Writing NSImage (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: How to create an animated gif?
  • Next by Date: Re: UIDocumentBrowserViewController and file package documents
  • Previous by thread: Writing NSImage
  • Next by thread: How to create an animated gif?
  • Index(es):
    • Date
    • Thread