Glad to hear!

And... come on!      (0xFF & V >> 24) is pretty self explanatory, isn't it?
:p

I can't even claim to fully understand it now, though it made sense at the
time.
The overall idea is that you're "unpacking" that 32 bit int, 8 bits at a
time.

So, for RED, you're shifting those 32 bits 24 bits to the right
(essentially leaving you with the first 8 bits only) , and then multiplying
(bitwise AND) with an 8-bit white mask (0xFF). I think for the red channel
you probably wouldn't even need this, as you are already left with only 8
bits, so probably don't need to mask anything (can't verify right now,
though)

For GREEN, you're shifting 16 bits, meaning you have discarded the last 16
(blue and alpha), and you are left with green (first 8 bits) and red. Then
you multiply this with an 8 bit mask (0xFF), which leaves you with just the
8 bits of the green channel (256 possible values), and divide by 255 to get
it in a 0-1 range.

(same for blue, shifting only 8 bits to the right)

I *think* that's the gist of it, but it's been a while...

Cheers,
Ivan

On Sun, Dec 27, 2015 at 11:27 PM, Frank Rueter|OHUfx <[email protected]>
wrote:

> Sweet, thanks Ivan!
> I won't even try to understand this but it works.
>
> frank
>
>
>
> On 28/12/15 8:25 pm, Ivan Busquets wrote:
>
> Hey Frank,
>
> Found this buried inside some old backdrop-utilities module. I think it
> should work for what you're after.
>
> def TILEtoRGB(V):
>
>     '''
>
>     TILEtoRGB(V) -> tuple
>
>     Returns a tuple representing Red, Green, and Blue values
>
>     in a 0-1 range, from a 32 bit int as returned by the "tile_color" knob.
>
>     Keyword arguments:
>
>     V -- a 32 bit int as returned by the "tile_color" knob
>
>     '''
>
>
>     R = (0xFF & V >> 24) / 255.0
>
>     G = (0xFF & V >> 16) / 255.0
>
>     B = (0xFF & V >> 8) / 255.0
>
>     return R,G,B
>
>
>
> Hope it helps!
>
>
>
> On Sun, Dec 27, 2015 at 11:11 PM, Frank Rueter|OHUfx <[email protected]>
> wrote:
>
>> Hi guys,
>>
>> after years of begrudgingly having to convert rgb to tile colour friendly
>> values, I now need to do the opposite, i.e. take a tile color value and get
>> rgb values from it.
>>
>> How do I do that?
>>
>> Cheers,
>> frank
>>
>>
>> --
>> [image: ohufxLogo 50x50] <http://www.ohufx.com> *vfx compositing
>> <http://ohufx.com/index.php/vfx-compositing> | workflow customisation and
>> consulting <http://ohufx.com/index.php/vfx-customising> *
>>
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected], http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>
>
> _______________________________________________
> Nuke-python mailing [email protected], 
> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
> --
> [image: ohufxLogo 50x50] <http://www.ohufx.com> *vfx compositing
> <http://ohufx.com/index.php/vfx-compositing> | workflow customisation and
> consulting <http://ohufx.com/index.php/vfx-customising> *
>
> _______________________________________________
> Nuke-python mailing list
> [email protected], http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to