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:
- Create the graphics context: UIGraphicsBeginImageContext(size);
- Create gradient object: CGGradientCreateWithColorComponents
- Draw the image (photo loaded from photo library) to the scale of the screen: drawInRect
- Set to an overlay blend mode: CGContextSetBlendMode
- Draw the gradient: CGContextDrawRadialGradient
- Create a UIimage from using UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- Draw the completed image to screen: drawInRect.
Is there a faster way to draw? perhaps using opengl?
Any suggestions/sample code would be appreciated.
Thanks.