We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Bit Shifting HSB
Page Index Toggle Pages: 1
Bit Shifting HSB (Read 348 times)
Bit Shifting HSB
Feb 19th, 2009, 2:35am
 
I see that the RGB values of a Color can be extracted by bit shifting.  Is there a similar, fast, technique for extracting the HSB values rather than calling hue(), saturaion(), and brightness()?  I am mainly interested in the saturation right now.
Re: Bit Shifting HSB
Reply #1 - Feb 19th, 2009, 9:51am
 
I fear no.
I tried:

 colorMode(HSB, 255);
 color c = color(0xFF, 0xAA, 0x55);
 println(hex(c));

It looks like colors are actually converted to RGB before storage. Which make sense: Java will internally store color information for images in RGB too.

That's why we have slower methods red green blue hue saturation brightness, to do the conversions needed by colorMode (not only mode, but also range).
The bit shifting shortcut works only in the default mode.

So in all cases, you can only convert RGB information to HSB, perhaps with an algorithm slightly faster than Processing's one (by skipping scaling), but the gain is probably marginal anyway. Well, you can try and see if it improves anything.
Re: Bit Shifting HSB
Reply #2 - Feb 19th, 2009, 4:24pm
 
Thx. for looking into it.
Page Index Toggle Pages: 1