• 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
- [NSBitmapImageRep cacheDisplayInRect:toBitmapImageRep:] produces empty image
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

- [NSBitmapImageRep cacheDisplayInRect:toBitmapImageRep:] produces empty image


  • Subject: - [NSBitmapImageRep cacheDisplayInRect:toBitmapImageRep:] produces empty image
  • From: Ben Lachman <email@hidden>
  • Date: Wed, 19 Aug 2009 17:50:22 -0400

I have an offscreen window containing a WebView that I'm using to generate web previews. My current code works beautifully and looks like this:

NSView *view = previewWebView.mainFrame.frameView.documentView;

NSRect targetRect = view.bounds;

NSBitmapImageRep *imageRep = [view bitmapImageRepForCachingDisplayInRect:targetRect];
unsigned char *bitmapData = [imageRep bitmapData];

if (bitmapData != NULL)
bzero(bitmapData, [imageRep bytesPerRow] * [imageRep pixelsHigh]);

[view cacheDisplayInRect:targetRect toBitmapImageRep:imageRep];

NSImage *renderedImage = [[NSImage alloc] initWithSize:[imageRep size]];
[renderedImage addRepresentation:imageRep];


However, I'm really only interested in the first page or so of data. So I figure I just make targetRect smaller by making the height the same as the width (if it's larger) prior to creating the image rep, like so:

	if( NSHeight(targetRect) > NSWidth(targetRect) )
		targetRect.size.height = NSWidth(targetRect);

This either produces an empty image rep or a chunk of the image the size of the intersection of the visible area of view and the rect you'd get if targetRect was aligned to the bottom left (however view is flipped). Manipulating targetRect doesn't seem to help.

I'm stumped, any ideas?

->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: email@hidden
twitter: @benlachman
mobile: 740.590.0009



_______________________________________________

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


  • Follow-Ups:
    • Re: - [NSBitmapImageRep cacheDisplayInRect:toBitmapImageRep:] produces empty image
      • From: "Adam R. Maxwell" <email@hidden>
  • Prev by Date: Re: devil of a time with an NSImageView
  • Next by Date: Re: Core Data dog-slow when using first time after boot
  • Previous by thread: Re: bound popup cell not letting me set it's value
  • Next by thread: Re: - [NSBitmapImageRep cacheDisplayInRect:toBitmapImageRep:] produces empty image
  • Index(es):
    • Date
    • Thread