PDA

View Full Version : Create rounded corner image in iphone




arnieterm
Apr 14, 2009, 05:22 AM
In my iphone app, after selecting an image from iphone photo library, I am be able to resize the returned image to 60X60 but I need to make that image rounded cornered. How can we do it?
As I have to save the rounded cornered and resized image only.
Thanks
Arnieterm



robbieduncan
Apr 14, 2009, 05:33 AM
Create a rounded rect as a path.
Set this as the clipping path.
Draw the image into a new image.
Save.

arnieterm
Apr 14, 2009, 05:52 AM
Can you suggest a sample code for this as I am not familiar with iphone much
Thanks
Arnieterm

johnnyjibbs
Apr 14, 2009, 06:40 AM
Can you suggest a sample code for this as I am not familiar with iphone much
Thanks
Arnieterm
Try reading the 2D Graphics and Animation Guide (or something like that) on the Apple iPhone developer website - it shows you how to use the simple Core Graphics commands to draw lines and arcs (for rounded rectangles).

If I get a chance, next time I'm at my Mac I'll post some example code of how to draw a rounded rectangle path, then you just need to fill with the image you want.

robbieduncan
Apr 14, 2009, 06:42 AM
Probably the QuartzDemo (http://developer.apple.com/iphone/library/samplecode/QuartzDemo/index.html) will show you more than you need to know.

The documentation on building paths (http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211-SW6) and then clipping to a path (http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_paths/dq_paths.html#//apple_ref/doc/uid/TP30001066-CH211-TPXREF126) would cover steps 1) and 2) from my suggestion.

The image documentation (http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_images/dq_images.html#//apple_ref/doc/uid/TP30001066-CH212-CJBBGCII) should cover everything else.

As per usual: read the documentation: it's there to help you understand what's going on.

Yogachitra
Jul 15, 2009, 04:11 AM
Hi arnieterm,

Could you please tell me how did you resize image to 60 x 60? I could not achieve that...

Thanks in advance..

Yoga.