Skip to content

Instantly share code, notes, and snippets.

@GiantRobato
Created August 4, 2018 04:42
Show Gist options
  • Save GiantRobato/e96c46253c06635ec5cb51291e28430b to your computer and use it in GitHub Desktop.
Save GiantRobato/e96c46253c06635ec5cb51291e28430b to your computer and use it in GitHub Desktop.
unpacks rgb data using python
import zlib
import struct
#in while loop
try:
chunkType = bytes(chunkType).decode('utf-8')
if chunkType == 'IDAT':
deflated = zlib.decompress(data)
(a,r,g,b) = struct.unpack('<BBBB',deflated)
print('argb value is: [{},{},{},{}]'.format(a,r,g,b))
except Exception as e:
print(e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment