Skip to content

Instantly share code, notes, and snippets.

@ilebedie
Created October 29, 2015 16:44
Show Gist options
  • Save ilebedie/532900c6852b97b15802 to your computer and use it in GitHub Desktop.
Save ilebedie/532900c6852b97b15802 to your computer and use it in GitHub Desktop.
Convert rgba 10bit to 8 bit, cut last vertical and horizontal lines and changing channel layout
import numpy as np
x = np.fromfile(r'1920x1080BGRA16.raw', np.uint16)
y = x/256
z= y.astype(np.uint8)
z.tofile('1920x1080BGRA.raw')
w= np.zeros((1919*1079*4), np.uint8)
for i in range(1079):
#cut with reordering BGRA -> ARGB
for j in range(1919):
w[j*4 + 1919*4*i ] = z[j*4 + 3 + 1920*4*i]
w[j*4 + 1 + 1919*4*i ] = z[j*4 + 2 + 1920*4*i]
w[j*4 + 2 + 1919*4*i ] = z[j*4 + 1 + 1920*4*i]
w[j*4 + 3 + 1919*4*i ] = z[j*4 + 1920*4*i]
#simple cut
#w[1919*4*i:1919*4*(i+1)] = z[1920*4*i:1920*4*i+1919*4]
w.tofile('1919x1079ARGB_8b.raw')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment