I'm working on a image manipulation app that overlays a radial gradient over an image loaded from the photo library.
On screen I have a slider to dynamically in/decrease the radius of the radial gradient. I've found the performance on the simulator to be just fine, but on an iPhone 3G or 3GS it is much slower to redraw when moving the slider.
I'm currently using CGContextDrawRadialGradient
for drawing. The steps I'm following for every redraw:
UIGraphicsBeginImageContext(size)
;CGGradientCreateWithColorComponents
drawInRect
CGContextSetBlendMode
CGContextDrawRadialGradient
UIGraphicsEndImageContext();
drawInRect
.Is there a faster way to draw? Perhaps using OpenGL?
Any suggestions/sample code would be appreciated.
Thanks.
Here are some ideas that might improve performance
(assuming you're using the gradient to add vignetting to the image):
CGLayer
that has the same size as the view, this avoids scaling each time you need to draw it.CGLayer
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With