You may also need to adjust the data a bit depending on your image data format. For example, raw12, is packed into bits 0-13 with bits 0 and 1 being copies of the most significant bits of the pixel. See ‘27.10.6 RAW Memory Formats’ of the Parker TRM.
raw12:
15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
00 00 D11 D10 D09 D08 D07 D06 D05 D04 D03 D02 D01 D01 D11 D10