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 06-02-2008, 11:38 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 312
jonc is an unknown quantity at this point
Send a message via AIM to jonc
Default Fuzzy graphics when CGRect given float value

Has anyone else noticed that UIObjects are fuzzy if you set any of their values in the rect of their frame to float values? This makes sense, but I wasn't sure if it was intended behavior. For example, I have a label that I wan't to place dynamically depending on the size of a cell's content view:

Code:
weightLbl.frame = CGRectMake((self.contentView.frame.size.width * 0.445), weightLbl.frame.origin.y, weightLbl.frame.size.width, weightLbl.frame.size.height);
If I use that line the label shows up a little bit "fuzzy" looking on the screen. I figured out a workaround though, I just have to cast the result of that multiplication as an int, like this:

Code:
weightLbl.frame = CGRectMake(((int)(self.contentView.frame.size.width * 0.445)), weightLbl.frame.origin.y, weightLbl.frame.size.width, weightLbl.frame.size.height);
I would think that it would convert the frame to an integer just thinking from a graphics perspective. Do you all think that is supposed to be happening?
jonc is offline   Reply With Quote
Old 06-02-2008, 01:35 PM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 802
scottiphone is on a distinguished road
Default Re: Fuzzy graphics when CGRect given float value

As I recall on the Mac the drawing happens at .5 for auto-antialias. You coudl try offsetting as well and see if that works.
scottiphone is offline   Reply With Quote
Old 06-02-2008, 07:37 PM   #3 (permalink)
Registered Member
 
Join Date: Apr 2008
Posts: 93
BuschyBoy is an unknown quantity at this point
Default Re: Fuzzy graphics when CGRect given float value

Just on the simulator or on the device itself, too?
BuschyBoy is offline   Reply With Quote
Old 06-03-2008, 12:00 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 312
jonc is an unknown quantity at this point
Send a message via AIM to jonc
Default Re: Fuzzy graphics when CGRect given float value

I think it was on both the simulator and the phone actually. It could have been because I was accidentally (lol) laying out my view in the drawrect method of a table cell, but I had cast everything as an int before I took it out. It can confirm it was doing it in drawrect though. I will try it again when I get to work tomorrow because that is strange. It didn't look pretty like anti-aliasing, it looked fuzzy.

It could have been that the tiny drop shadow on the text was making the anti-aliasing look like blur.
jonc is offline   Reply With Quote
Old 06-03-2008, 10:13 AM   #5 (permalink)
New Member
 
Join Date: Apr 2008
Posts: 420
jeff_lamarche is an unknown quantity at this point
Send a message via AIM to jeff_lamarche Send a message via Yahoo to jeff_lamarche
Default Re: Fuzzy graphics when CGRect given float value

The engine that drives the graphics on the iPhone (and the Mac) are designed to be device and resolution independent, so if you give it a floating point value, it will do its best to give you what you want, most likely by anti-aliasing the pixels on either side of the value you specified.

That's my guess from working with Quartz on the Mac, though, I haven't dived much into custom drawing yet on the iPhone.
__________________
Check out my iPhone Dev Blog
You can send me e-mail at my forum username at mac dot com.
jeff_lamarche is offline   Reply With Quote
Old 06-03-2008, 10:09 PM   #6 (permalink)
Registered Member
 
Join Date: Apr 2008
Location: Colorado
Posts: 312
jonc is an unknown quantity at this point
Send a message via AIM to jonc
Default Re: Fuzzy graphics when CGRect given float value

That seems to be the what is happening so the iPhone must do it too. I didn't know that, it makes a lot more sense why everything looks prettier in Mac OS and on the iPhone.

Try giving your text a drop shadow with a size of (0.5,0.5), it looks pretty.
jonc is offline   Reply With Quote
Reply

Bookmarks

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: 334
4 members and 330 guests
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,880
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:43 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0