Reply to topic  [ 4 posts ] 
More programming stuff... 
Author Message
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Hi Guys,

I'm trying to do some work with colours (RGB values, etc...).

The control that I have returns an integer and I have found a function that converts the integer into separate red, green and blue values.

But it isn't working.

The function I found is...

input colourvalue.

redvalue = colourvalue MOD 256.
greenvalue = (colourvalue / 256) MOD 256.
bluevalue = (colourvalue / 256 / 256) MOD 256.

This seems to almost work but not quite.

I have put the same formulae into Excel to check it is working correctly and it does.

For instance, when I click a cyan like colour RGB(0,255,255). The int returned is 16776960. Excel turns this into 0,255,255 but my program thyinks it is 0,255,0.

Simililarly when I select white, Excel says it is 255,255,255 but my program thinks it is 255,0,0.

Not sure what could be going on here.

Any ideas?!

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Fri Dec 11, 2009 9:31 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
Woohoo!

Truncate is your freind!

Stupid thing

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Fri Dec 11, 2009 9:34 am
Profile WWW
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 9:40 pm
Posts: 5288
Location: ln -s /London ~
Reply with quote
I'd check the double-division for the blue one and add some extra brackets to be safe/clear.

_________________
timark_uk wrote:
Gay sex is better than no sex

timark_uk wrote:
Edward Armitage is Awesome. Yes, that's right. Awesome with a A.


Fri Dec 11, 2009 9:35 am
Profile
I haven't seen my friends in so long
User avatar

Joined: Thu Apr 23, 2009 7:35 pm
Posts: 6580
Location: Getting there
Reply with quote
EddArmitage wrote:
I'd check the double-division for the blue one and add some extra brackets to be safe/clear.

That's what I thought is might be but it's down to rounding. The program was being too clever and turning 255.56738239... into 256. I needed to truncate instead.

_________________
Oliver Foggin - iPhone Dev

JJW009 wrote:
The count will go up until they stop counting. That's the way counting works.


Doodle Sub!
Game Of Life

Image Image


Fri Dec 11, 2009 9:42 am
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.