Question: I've got a stream coming from a camera that is set to a 12 bit pixel format.
My question is how can i store the pixel values in an array?

Before i was taking pictures with a 16 bit pixel format, but now i changed to 12 bit and I get the same full size image displayed four images on the screen next to one another I used to store the values in an ushort array then.

When i have the camera set to 8 bit pixel format I store the data in a byte array, but what should I use when having it at 12 bit?

Answer: 
Following on from my comment, we can process the incoming stream in 3-byte "chunks", each of which give 2 pixels.

```
// for a "chunk" of incoming array a[0], a[1], a[2]
ushort pixel1 = ((ushort)a[0] << 4) | ((a[1] >> 4) & 0xFF);
ushort pixel2 = ((ushort)(a[1] & 0xFF) << 4) | a[2];

```

(Assuming big-endian)
The smallest memory size you can allocate is one byte (8 bits) that means that if you need 12 bits of data to store one pixel in your frame array you should use `ushort`. And leave the 4 bits alone . That’s why it’s more efficient to design these kind of stuff with numbers from the pow of two
(1 2 4 8 16 32 64 128.. etch)