Jump to content
Sign in to follow this  
Patrick Winkler

Convert 8 Bit RGB to 16 Bit

Recommended Posts

Hello,

I need to convert from 8 bit RGB to 16 bit.

Just miltipling every value by 256 will come close but not exact:

RGB_8Bit = (255,0,160)

RGB_16Bit = []

for i in RGB_8Bit:

RGB_16Bit.append ( i * 256 )

can someone provide a better algorithm

Edited by Patrick Winkler

Share this post


Link to post

thanks,

that seems to come closer but is still not exact:

r8bit = 0

print ( ((r8bit + 1) * 256) - 1 )

>> 255 // Should be 0

Edited by Patrick Winkler

Share this post


Link to post

16bitColor = 8bitColor * 257

And conversely,

8bitColor = 16bitColor / 257

0 <-> 0

255 <-> 65535

values in between are evenly distributed between the two end values.

Raymond

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×