Converting 24bits to 16bits color format error
Posted: Fri Aug 13, 2021 10:32 am
I'm trying to convert 24 bits to 16 bits but it gave me the error:
"NameError: name 'format' isn't defined"
How do I use the format method?
"NameError: name 'format' isn't defined"
How do I use the format method?
Code: Select all
def colorMenu():
global r,g,b,
blue = int(b/8)
red = int(r/4)
green = int(g/8)
print('blue: '+bin(blue))
print('red: '+bin(red))
print('green: '+bin(green))
newb = format(blue,'#07b')[2:]+'00000000000'
newr = '00000' + format(red,'#08b')[2:]+ '00000'
newg = '00000000000'+ format(green,'#07b')[2:]
print('new blue: '+newb)
print('new red: '+newr)
print('new green: '+newg)
colour = int(newb,2)+int(newr,2)+int(newg,2)
print(bin(colour))
nc = '0b'+format(colour,'#018b')[2:]
print(nc)