24位RGB转换为ARGB16 [英] convert 24bit RGB to ARGB16

查看:697
本文介绍了24位RGB转换为ARGB16的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要读 24 bpp的位图 RGB24 每个像素转换成 ARGB16

I have to read a 24bpp Bitmap and convert each pixel from RGB24 to ARGB16.

我用下面的code,

#define ARGB16(a, r, g, b) ( ((a) << 15) | (r)|((g)<<5)|((b)<<10))

但我没有得到所需的输出。

But I am not getting the required Output.

任何帮助将是非常美联社preciated。

Any help would be highly appreciated.

推荐答案

打破它。让我们继续使用宏:

Break it up. Let's continue to use macros:

#define TRUNCATE(x)  ((x) >> 3)

#define ARGB16(a,r,g,b) ((a << 15) | (TRUNCATE(r) << 10) | (TRUNCATE(g) << 5) | TRUNCATE(b)))

这假定阿尔法只是一个位。

This assumes the alpha is just a single bit.

这篇关于24位RGB转换为ARGB16的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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