问题描述
这是我老师的分配,但我认为在''正常'的条款中意味着:
写一个带RGB(r,g,b)的函数; r,g和b是0到31之间的值;然后它将其转换为16位RGB。
我不知道该怎么做,或者它意味着什么。
提前谢谢。
That''s the assigment from my teacher, but i think in ''normal'' terms that means:
Write a function that takes RGB(r,g,b); r, g and b being values between 0 and 31; it then converts it to 16 bit RGB.
I haven''t a clue how to do that, or what it means.
Thanks in advance.
推荐答案
请注意,[0,31]范围内的值占用5位。其中三个旁边每个
其他占15位。这非常适合16位字。看看位移
运算符<<和>>
亲切的问候,
Jos
Note that a value in the range [0, 31] takes up 5 bits. Three of them next to each
other take up 15 bits. That fits nicely in a 16 bit word. Have a look at the bit shift
operators << and >>
kind regards,
Jos
那个对我来说并不是很重要。我没有做太多的比特,比特移位等。
That doesn''t really mean much to me. I haven''t done much with bits, bit shift etc..
嗯:开始阅读。
kind问候,
Jos
Well: start reading then.
kind regards,
Jos
这篇关于C - 将RGB(31,31,31)转换为16位颜色。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!