Re: How to replace image contents?
Re: How to replace image contents?
- Subject: Re: How to replace image contents?
- From: Samvel <email@hidden>
- Date: Wed, 9 Apr 2008 22:02:16 -0500
It was a general thought. I am programming in Objective-C only for
about month and was wondering if there is any faster way to replace
image/string/etc. contents instead of reallocating object itself.
Samvel.
On Apr 9, 2008, at 9:58 PM, Bill Bumgarner wrote:
On Apr 9, 2008, at 7:43 PM, Samvel wrote:
But these lines of code involves freeing memory and allocating new
object although it seems to be faster if data would be replaced
instead of recreating the whole object. Is it possible to do that
way: just to replace image contents with newImageData without
reallocating new object?
Not via the NSImage API. You could use an NSBitmapImageRep instead.
However, have you run Shark or Instruments to determine if this is
actually a performance issue?
More likely, most of your CPU cycles are being consumed by actually
changing out the image data and very few cycles are consumed by the
allocation of the wrapper object.
Before you bother with NSBitmapImageRep, I would highly recommend
using the provided tools to figure out what needs to be optimized
first.
b.bum
BTW: NSBitmapImageRep has the honor of having the single longest
method declaration of any class in Mac OS X. Or, at least, I think
it does.
- (id)initWithBitmapDataPlanes:(unsigned char **)planes pixelsWide:
(int)width pixelsHigh:(int)height bitsPerSample:(int)bps
samplesPerPixel:(int)spp hasAlpha:(BOOL)alpha isPlanar:
(BOOL)isPlanar colorSpaceName:(NSString *)colorSpaceName
bitmapFormat:(NSBitmapFormat)bitmapFormat bytesPerRow:(int)rBytes
bitsPerPixel:(int)pBits;
(There might have been a method in EOF that was actually longer)
_______________________________________________
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