Advertisement
Guest User

ARGB --> RGBA

a guest
Mar 7th, 2015
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. bytelist = list(b'abcdabcdabcd')
  2.  
  3. splits = len(x) // 4
  4. arraysplits = []
  5. current = 0
  6. for i in range(1, splits+1):
  7.     arraysplits.append((current, 4*i))
  8.     current = 4*i
  9.  
  10. splitbytes = []
  11. for idx in arraysplits:
  12.     splitbytes.append(bytelist[idx[0]:idx[1]])
  13.  
  14. rgbalist = []
  15. for argb in splitbytes:
  16.     rgba = argb[1:] + [argb[0]]
  17.     rgbalist.append(rgba)
  18.  
  19. finalbytes = bytearray()
  20. for rgba in rgbalist:
  21.     for byte in rgba:
  22.         finalbytes.append(byte)
  23.  
  24. finalbytes = bytes(finalbytes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement