Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions about CGImage



Hi!

I am new to this mailing list and to Quartz in general. I have taken on the big task of trying to recreate (as much as possible of) iPhoto's main thumbnail view. Up until now, I've been working with NSBitmapImageRep's under Cocoa. Even though that already yielded nice results in speed, I am sure that it can still be improved.

I tried to change my drawing parts to Quartz 2D. However, this produced a noticeably SLOWER execution. I used Shark on both versions and realized that obviously my Quartz version constantly re-loads the JPEG data. Here is the complete Quartz-part:

	/* Adding an image */
	CGImageRef image;
	CGDataProviderRef provider;
	CFStringRef path;
	CFURLRef url;
	path = CFStringCreateWithCString (NULL, [theImagePath UTF8String],
									  kCFStringEncodingUTF8);
    	url = CFURLCreateWithFileSystemPath (NULL, path,
										 kCFURLPOSIXPathStyle, NULL);
	CFRelease(path);
	provider = CGDataProviderCreateWithURL (url);
	CFRelease (url);
	image = CGImageCreateWithJPEGDataProvider (provider,
											   NULL,
											   true,
											   kCGRenderingIntentDefault);
    	CGDataProviderRelease (provider);
	
	// Is this a good idea? It works, nevertheless...
	[images addObject:(NSObject*)image];
	
	CGImageRelease (image);

Here is the part inside the drawRect: method of my custom view:

CGContextRef currentContext = (CGContextRef) [[NSGraphicsContext currentContext] graphicsPort];

for (i=startingIndex; i<endingIndex; i++) {
. . .
CGImageRef currentImage = (CGImageRef)[images objectAtIndex:i];
// the following function is a #define for the conversion
CGRect re = NSRectToCGRect(NSMakeRect(x, y, xSize, ySize));

CGContextDrawImage (currentContext, re , currentImage);
. . .
}


And finally, here is an excerpt of what Shark tells me:

	15.3%	15.3%	CoreGraphics	jpeg_idct_islow	
	11.2%	11.2%	CoreGraphics	decode_mcu	
	7.0%	7.0%	CoreGraphics	jpeg_fill_bit_buffer	
	6.1%	6.1%	CoreGraphics	h2v1_fancy_upsample

What am I doing wrong? Any help/hints/pointers to (good & thorough) documentation is greatly appreciated!

Cheers,
Michael

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.