Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 02-12-2009, 03:38 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Bangalore, India
Posts: 33
Xcode.warrior is on a distinguished road
Default Filling/Drawing an Image into an Ellipse

Hi,

Firstoff, I'm a newbie to Cocoa frameworks, Objective-C and iPhone development.
I'm working on an application, wherein I've decided to put an image in the ellipse which I'm filling up into a rectangle, using the normal method:
Code:
CGContextFillEllipseInRect()
Now, I've been through the API reference, but I couldn't figure out a way to do this.
Can anyone suggest me something in this regards?

And also related to the same app, I've another question: Is it possible to get a border around your rects and ellipse? how can you achieve it?

Thanks for reading through, appreciate your help.
Xcode.warrior is offline   Reply With Quote
Old 02-12-2009, 11:38 AM   #2 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
RickMaddy will become famous soon enough
Default

Read the Quartz 2D Programming Guide and look at the section on clipping regions. You are going to want to set the ellipse as a clipping region then draw the image.
RickMaddy is offline   Reply With Quote
Old 02-13-2009, 02:47 AM   #3 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Bangalore, India
Posts: 33
Xcode.warrior is on a distinguished road
Default

Quote:
Originally Posted by RickMaddy View Post
Read the Quartz 2D Programming Guide and look at the section on clipping regions. You are going to want to set the ellipse as a clipping region then draw the image.
Hi,

I've been through Quartz 2D Programming documentation and I have even created my application with an image clipped by the ellipse.
But my query is, how to display the image without clipping it inside the ellipse. To further elaborate this, i've attached a logoEllipse.png file.
In the attached, the rectangle represents the image's rectangle. When I use the normal:
Code:
CGContextAddInRect() or CGcontextFillEllipseInRect()
method, I'd get the small ellipse shown inside the rectangle, clipping the rest of the image. What I'm actually looking for is, the way to put the image, inside an ellipse, which is represented by the outer, bigger ellipse.
I've tried work arounds here and there, but could not achieve the desired effect.
If anyone have any suggestion, I'll appreciate it.

Thanks.
Attached Images
File Type: png logoEllipse.png (2.7 KB, 20 views)
Xcode.warrior is offline   Reply With Quote
Old 02-13-2009, 10:42 AM   #4 (permalink)
Registered Member
 
RickMaddy's Avatar
 
Join Date: Oct 2008
Location: Denver, CO
Posts: 2,121
RickMaddy will become famous soon enough
Default

OK, I think I understand what you want now. Draw the bigger ellipse first. Then you need to draw the image with a smaller rectangle than used by the ellipse. A little trial and error should give you the correct ratio of the two rectangles so the image just fits inside the outer ellipse.
RickMaddy is offline   Reply With Quote
Old 02-16-2009, 04:56 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Location: Bangalore, India
Posts: 33
Xcode.warrior is on a distinguished road
Default

Quote:
Originally Posted by RickMaddy View Post
OK, I think I understand what you want now. Draw the bigger ellipse first. Then you need to draw the image with a smaller rectangle than used by the ellipse. A little trial and error should give you the correct ratio of the two rectangles so the image just fits inside the outer ellipse.
Hi RickMaddy,
you're right. I'll do that. I guess a little trial and error should do the trick.
Actually, the reason why I'd asked this query was that, I thought that, there might be a method/tricky workaround somewhere, through which we can draw the ellipse outside the rectangle( and since being a new-born in the Xcode-world, I thought to ask over here to clarify it)
anyways, Thanks for the responses. I think those really helped me alot to proceed further.
Xcode.warrior is offline   Reply With Quote
Old 01-20-2012, 12:59 PM   #6 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
smartboyseua is on a distinguished road
Default

Hiii.. I'm new in this forum,and in objective-c too... and this is my first post
So the question is...
How can i draw sectors in the ellipse...?? or how can i get random point coordinates from the ellipse...
Thanks in advance
smartboyseua is offline   Reply With Quote
Reply

Bookmarks

Tags
draw, ellipse, fill, uiimage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 327
5 members and 322 guests
Anwerbl, guusleijsten, HowEver, LEARN2MAKE, mottdog
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,879
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:38 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0