• 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
NSImage lock/unlock slow
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSImage lock/unlock slow


  • Subject: NSImage lock/unlock slow
  • From: email@hidden
  • Date: Sun, 2 Dec 2007 02:16:33 +0100

Hi

I am trying to get an idea of what is fast efficient and so on.

In my case the origin is a NSBitmapImage that I want cutout a portion from and scale that portion into a new NSBitmapImage.


for (int i = 0; i < 10000; i++) {
// Create a NSImage from NSBitmapImageRep
NSImage *sourceImage = [NSImage alloc];
[sourceImage addRepresentation:image];
[sourceImage setFlipped:true];

// Create a new NSImage
NSRect targetRect = NSMakeRect(0, 0, 20, 20);
NSImage *targetImage = [[NSImage alloc] initWithSize: targetRect.size];
[targetImage setFlipped:true];

[targetImage lockFocus];
// Draw a part from source into target and stretch/shrink
[sourceImage drawInRect:targetRect fromRect:NSMakeRect(371, 179, 10, 10) operation:NSCompositeCopy fraction:1.0];

// Create a NSBitmapImageRep from locked NSImage
NSBitmapImageRep *targetRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect: NSMakeRect(0, 0, 20, 20)];
[targetImage unlockFocus];
[targetImage release];
[sourceImage release];
}


When running this code over and over again. approx 50% of the time is spent in lock/unlock and the other 50% in the drawInRect command.

I am a bit demotivated from the fact that the focus command is so expensive.
To my knowledge there is no way to get around this?????


THX
_______________________________________________

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: NSImage lock/unlock slow
      • From: "Ken Ferry" <email@hidden>
  • Prev by Date: Re: How can I check to see if a mounted volume is an iPod or not?
  • Next by Date: Request lower resolution from camera with QTKit
  • Previous by thread: Re: How can I check to see if a mounted volume is an iPod or not?
  • Next by thread: Re: NSImage lock/unlock slow
  • Index(es):
    • Date
    • Thread