mindbrix / UIImage-PDF

Simple UIImage PDF renderer category for iOS scalable assets
http://blog.mindbrix.co.uk/2012/02/10/ios-scalable-assets/
1.24k stars 155 forks source link

PDF image drawing efficiency #3

Closed joeshang closed 12 years ago

joeshang commented 12 years ago

Hi Nigel,

i tried UIImage+PDF and it worked well.But when i tried to compare with png image on consumption of time, pdf is 6 or 7 times than png. pdf is YingYang.pdf in your project, png has the same dimesions(480*479), iOS 5.0 simulator. I Modified your PDFView.m file like this:

NSLog(@"Start"); for (i=0; i<LoopTimes; i++) { CGContextDrawPDFPage( ctx, page1 ); //png is the same method like this } NSLog(@"End");

LoopTimes = 10, 100 or 1000, Do you have any advice on drawing efficiency?

Joe(From China, sorry for my poor english...)

mindbrix commented 12 years ago

Hi Joe. Greetings from London!

PDF rendering will always be slower than loading a bitmap. If performance is an issue I'd suggest caching the rendered UIImage objects in an NSDictionary.

Also, I'd recommend doing all performance testing on an actual device, as the simulator results can be very misleading.

Best, Nigel.

On 23 February 2012 13:21, jacloven < reply@reply.github.com

wrote:

Hi Nigel,

i tried UIImage+PDF and it worked well.But when i tried to compare with png image on consumption of time, pdf is 6 or 7 times than png. pdf is YingYang.pdf in your project, png has the same dimesions(480*479), iOS 5.0 simulator. I Modified your PDFView.m file like this:

NSLog(@"Start"); for (i=0; i<LoopTimes; i++) { CGContextDrawPDFPage( ctx, page1 ); //png is the same method like this } NSLog(@"End");

LoopTimes = 10, 100 or 1000, Do you have any advice on drawing efficiency?

Joe(From China, sorry for my poor english...)


Reply to this email directly or view it on GitHub: https://github.com/mindbrix/UIImage-PDF/issues/3

vectoria.co.uk

concentrichron.com

Mindbrix -- Dream it, draw it, build it, love it

69 Derby Street Beeston Nottingham NG9 2LG

+44 7905 311 352 nigel@mindbrix.co.uk www.mindbrix.co.uk Skype: ntbarber twitter.com/mindbrix

mindbrix commented 12 years ago

Hi Joe. UIImage+PDF now has a transparent cacheing layer to address this issue. Once cached, the performance should be comparable to using bitmaps from the application bundle.