Skip to content

Instantly share code, notes, and snippets.

@cwood1967
Created March 2, 2017 19:41
Show Gist options
  • Save cwood1967/40902aeef56dfe3ac24748173e515e59 to your computer and use it in GitHub Desktop.
Save cwood1967/40902aeef56dfe3ac24748173e515e59 to your computer and use it in GitHub Desktop.
short[] image = new short[size];
int index = 0;
for (int i = 0; i < fileBytes.length; i += 5) {
int s = 2;
int t0 = (fileBytes[i] & 0x00FF) << s;
int t1 = (fileBytes[i + 1] & 0x00FF) << s;
int t2 = (fileBytes[i + 2] & 0x00FF) << s;
int t3 = (fileBytes[i + 3] & 0x00FF) << s;
int lsb = (fileBytes[i + 4] & 0x00FF) << s;
t0 += (lsb & 3);
t1 += (lsb & 12) >> 2;
t2 += (lsb & 48) >> 4;
t3 += (lsb & 192) >> 6;
image[index] = (short)(t0 << 0);
image[index + 1] = (short)(t1 << 0);
image[index + 2] = (short)(t2 << 0);
image[index + 3] = (short)(t3 << 0);
index += 4;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment