• 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: Can't cache image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't cache image


  • Subject: Re: Can't cache image
  • From: Jan Van Tol <email@hidden>
  • Date: Fri, 21 Mar 2003 14:25:26 -0600

I've had this same problem, and I narrowed it down to simply creating a very large NSImage, then locking focus on it. I can have the exact same code start to give the can't cache image error simply by initing a larger image.

If anyone knows of a workaround, I would love to hear it.

-Jan Van Tol

On Friday, March 21, 2003, at 01:25 PM, Ben Mackin wrote:

On 3/21/03 9:22 AM, "Brock Brandenberg" <email@hidden> wrote:

The error is because you have told the NSImage to never cache. Because you
are telling it not to cache, it's responding that it can't create the
offscreen window buffer in which to capture and cache your subsequent
drawing after the lockFocus.

If you're trying to capture your drawing as a bitmap, you do this as covered
under "Caching Representations" in "Drawing and Imaging". You can then use
the NSBitmapImageRep for whatever you want:

NSImage* image = [[NSImage alloc] initWithSize:size];
[image lockFocus];

// draw draw draw

NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:
NSMakeRect(0,0,size.width,size.height)];
[image unlockFocus];

I tried that first (I should have mentioned that). I didn't have the
setCacheMode line in my code. But when I started getting the "Can't cache
image" error, I figured I need to set the NSImage to not cache (I guess I
understood the error wrong).

So any other thoughts on what could be the issue? Could it be that init my
NSImage with just a size is not good enough to then lockFocus on? Sorry I am
pretty new to Cocoa, so I hope this isn't obvious (I tried searching the
archives).

Thanks,
Ben

http://www.shayufilms.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Can't cache image
      • From: Greg Titus <email@hidden>
References: 
 >Re: Can't cache image (From: Ben Mackin <email@hidden>)

  • Prev by Date: Re: Sheet over a sheet ?
  • Next by Date: Re: Sheet over a sheet ?
  • Previous by thread: Re: Can't cache image
  • Next by thread: Re: Can't cache image
  • Index(es):
    • Date
    • Thread