Python: reading 12 bit packed binary image

牧云@^-^@ 提交于 2019-12-04 06:52:40

With this code

for oo in range(0,len(data)/3):
  aa = bitstring.Bits(bytes=data[oo:oo+3], length=24)

you are reading bytes data[0:3], data[1:4], ... What you actually want is probably this:

for oo in range(0,len(data)/3):
  aa = bitstring.Bits(bytes=data[3*oo:3*oo+3], length=24)

[EDIT] Even more compact would be this:

for oo in range(0,len(data)-2,3):
  aa = bitstring.Bits(bytes=data[oo:oo+3], length=24)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!