我尝试将图片转换为以下DDS格式:
| Resource Format | dwFlags | dwRGBBitCount | dwRBitMask | dwGBitMask | dwBBitMask | dwABitMask |
+-----------------+----------+---------------+------------+------------+------------+------------+
| D3DFMT_A4R4G4B4 | DDS_RGBA | 16 | 0xf00 | 0xf0 | 0xf | 0xf000 |
D3DFMT_A4R4G4B4 16位ARGB像素格式,每个通道有4位。
我有这个python代码(使用Wand lib):
# source is jpeg converted to RGBA format (wand only supports RGBA not ARGB)
blob = img.make_blob(format="RGBA")
for x in range(0, img.width * img.height * 4, 4):
r = blob[x]
g = blob[x + 1]
b = blob[x + 2]
a = blob[x + 3]
# a=255 r=91 g=144 b=72
pixel = (a << 12 | r << 8 | g << 4 | b) & 0xffff
我得到的第一个像素是64328
,但我期待62868
。
问题: