• 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
Image from WebView is sometimes blank
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Image from WebView is sometimes blank


  • Subject: Image from WebView is sometimes blank
  • From: Duncan Oliver <email@hidden>
  • Date: Tue, 11 May 2010 16:33:07 -0500

I have a WebView that I use to capture a thumbnail of a loaded webpage
using cacheDisplayInRect:. The WebView object is created
programmatically and not attached to a window. About half the time,
the image it grabs is blank. I can't seem to figure out if I'm trying
to grab it too soon or what. Would love to know how to get a completed
image all the time. Thanks in advance.

Here's the code:

- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame
{
	if ([frame isEqualTo:[sender mainFrame]])
	{
		if ([sender saveThumbnail] == YES)
		{
			NSView *mainFrameView = sender.mainFrame.frameView;
			NSBitmapImageRep *thumbnailImageRep = [mainFrameView
bitmapImageRepForCachingDisplayInRect:[mainFrameView frame]];
			[sender cacheDisplayInRect:[mainFrameView frame]
					  toBitmapImageRep:thumbnailImageRep];
			NSData *thumbnailPNGData = [thumbnailImageRep
representationUsingType:NSPNGFileType
																	   properties:nil];

			[[sender point] setValue:thumbnailPNGData
							  forKey:@"thumbnail"];
			…
			}
		}
	}
}
---
Duncan Oliver
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

  • Follow-Ups:
    • Re: Image from WebView is sometimes blank
      • From: "Adam R. Maxwell" <email@hidden>
  • Prev by Date: Re: Handling bindings of an NSControl which forward everything to an NSCell?
  • Next by Date: Re: Archiving NSBlockPredicate and NSPredicate date functions
  • Previous by thread: [MEET] LA CocoaHeads - Thursday 5/13 7:30pm
  • Next by thread: Re: Image from WebView is sometimes blank
  • Index(es):
    • Date
    • Thread