Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
squirreltown
Level 9

color convert

I have this color: &h404040FF
if i print it i get - 1077952767 and the roku understands it if i spec that instead of the hex color.
but I can't seem to find a hex/decimal/whatever conversion to get from:
this 1077952767
back to this:&h404040FF



thanks
Kinetics Screensavers
0 Kudos
24 Replies
destruk
Level 10

Re: color convert

http://www.netgfx.com/RGBaZR/

Select from UINT for the dropdown, enter your decimal value, and click convert.
0 Kudos
squirreltown
Level 9

Re: color convert

Thank you destruk, but i need to do it in my channel, so i need a formula, i'm just not finding the right one on the inter-tubes
Kinetics Screensavers
0 Kudos
Roku Employee
Roku Employee

Re: color convert

On firmware 6.1 or later you can use StrI to format hexadecimal.

color = &h404040FF
? "&h" + UCase(StrI(color, 16))
0 Kudos
squirreltown
Level 9

Re: color convert

"RokuKC" wrote:
On firmware 6.1 or later you can use StrI to format hexadecimal.

color = &h404040FF
? "&h" + UCase(StrI(color, 16))

Thank you! I had found SrtI, but didn't realize I could dump the whole color in there.
Kinetics Screensavers
0 Kudos
squirreltown
Level 9

Re: color convert

Ok so here are two colors:

varr.background = &h404040FF
? varr.background = 1077952767
color = 1077952767
? "&h" + UCase(StrI(color, 16)) = &h404040FF

however:

varr.blue = &h0889f7FF
? varr.blue = 143259647
color = 143259647
? "&h" + UCase(StrI(color, 16)) = &h889F7FF
which is only 5 digits for the color not 6 which results in a rather different color, a light yellow not a bright blue.

Whatsup here? the leading zero in the original blue hex spec? how to resolve this?
Thanks
Kinetics Screensavers
0 Kudos
squirreltown
Level 9

Re: color convert

Another case:
varr.red = &h911820FF
? varr.red = -1860689665
color = -1860689665
? "&h" + UCase(StrI(color, 16)) = &h-6EE7DF01

I seem to be missing something important here.
Kinetics Screensavers
0 Kudos
Roku Employee
Roku Employee

Re: color convert

"squirreltown" wrote:
Another case:
varr.red = &h911820FF
? varr.red = -1860689665
color = -1860689665
? "&h" + UCase(StrI(color, 16)) = &h-6EE7DF01

I seem to be missing something important here.


Yes, I see you are right and the color spec string would need to be left-padded with "0"s.

But if the hex conversion is treating it as signed, that is a problem... I did not realize it worked that way. Smiley Sad
0 Kudos
Roku Employee
Roku Employee

Re: color convert

At this point it is rather too hacky:

? "&h" + UCase(("000" + StrI(color >> 16, 16)).Right(4) + ("000" + StrI(color AND &hFFFF, 16)).Right(4))

But perhaps that would work. Sigh.
0 Kudos
squirreltown
Level 9

Re: color convert

That seems to work, I tried it with the red and blue colors that failed before and they returned correctly.
So thank you, I would not have figured it out.
I looked up Integer Bitshift Operators and a dull haze surrounded everything so I stopped reading it.
As far as the hacky part goes, i won't tell anyone if you don't.
Kinetics Screensavers
0 Kudos