Patrick Winkler Posted January 27, 2016 Share Posted January 27, 2016 (edited) 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 January 27, 2016 by Patrick Winkler Quote Link to comment
Miguel Barrera Posted January 27, 2016 Share Posted January 27, 2016 I think this would be a better approximation: 16bitColor = ((8bitColor + 1)*256) - 1 Quote Link to comment
Patrick Winkler Posted January 28, 2016 Author Share Posted January 28, 2016 (edited) thanks, that seems to come closer but is still not exact: r8bit = 0 print ( ((r8bit + 1) * 256) - 1 ) >> 255 // Should be 0 Edited January 28, 2016 by Patrick Winkler Quote Link to comment
MullinRJ Posted January 29, 2016 Share Posted January 29, 2016 16bitColor = 8bitColor * 257 And conversely, 8bitColor = 16bitColor / 257 0 <-> 0 255 <-> 65535 values in between are evenly distributed between the two end values. Raymond Quote Link to comment
Patrick Winkler Posted January 29, 2016 Author Share Posted January 29, 2016 Great! thank you. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.