C - 将RGB(31,31,31)转换为16位颜色。 [英] C - Convert RGB(31,31,31) to 16 bit colour.

查看:79
本文介绍了C - 将RGB(31,31,31)转换为16位颜色。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


1.写一个函数或宏,它取0到31之间的三个值,并将其转换为BGR 16位格式。例如,函数原型应该看起来像u16 BGR(u16 b,u16 g,u16 r);
1. Write a function or macro, which takes three values between 0 and 31, and converts this to BGR 16 bit format. For example, the function prototype should look like u16 BGR(u16 b, u16 g, u16 r);



这是我老师的分配,但我认为在''正常'的条款中意味着:


写一个带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.

推荐答案


这是我老师的分配,但我觉得正常的意思是:


写一个带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



请注意,[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..



这对我来说并不是很重要。我没有做太多的比特,比特转移等..
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位颜色。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆