• 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
Problem with capturing view contents
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with capturing view contents


  • Subject: Problem with capturing view contents
  • From: Gideon King <email@hidden>
  • Date: Mon, 23 Apr 2012 14:25:06 +1000

Hi, I have a view I am trying to capture using the following code:

    NSBitmapImageRep *rep = [view bitmapImageRepForCachingDisplayInRect:[view bounds]];
    [view cacheDisplayInRect:[view bounds] toBitmapImageRep:rep];

My view coordinates in a typical test case are as follows:

    "01_frame" = "{{0, 0}, {350, 190}}";
    "02_bounds" = "{{-98, -95}, {350, 190}}";

The image rep created is the right size, but the contents are drawn up and to the right in the image rep (by 98,95 pixels).

If I instead use the frame, the contents are in the right place in the image rep, but it only includes the portions of the image with positive x and y values (bottom right seeing as it's a flipped view).

If I create an image that is bigger by the amount of the negative origins of the bounds, the entire thing is drawn, but then I would need to crop the image afterwards, which would be very messy and memory hungry since my views can get pretty big.

I tried applying an affine transform before grabbing it, but that made no difference.

So is it possible to capture views where the bounds go into the negatives, and if so, how?


TIA

Gideon
_______________________________________________

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

  • Prev by Date: Re: Guidelines on using NSJSONSerialization
  • Next by Date: NSPopover ~ resize to match content?
  • Previous by thread: Redrawing overlay views
  • Next by thread: NSPopover ~ resize to match content?
  • Index(es):
    • Date
    • Thread