Skip to content

Instantly share code, notes, and snippets.

@yuriks
Forked from dennda/gist:1251646
Created September 29, 2011 19:15
Show Gist options
  • Save yuriks/1251653 to your computer and use it in GitHub Desktop.
Save yuriks/1251653 to your computer and use it in GitHub Desktop.
uint8* dest = malloc(width * height * 4);
short* src = imgData;
for (int i = 0; i < width * height; ++i) {
short x = *src++;
*dest++ = (x >> 8) & 0xFF;
*dest++ = x & 0xFF;
*dest++ = 0;
*dest++ = 0;
}
@dennda
Copy link

dennda commented Sep 29, 2011

        uint8* dest = (uint8*) malloc(width * height * 4);
        short* subscript = (short*) imgData;
        for (int i = 0; i < width * height; ++i) {
            short x = *subscript++;
            *dest++ = (x >> 8) & 0xFF;
            *dest++ = x & 0xFF;
            *dest++ = 255;
            *dest++ = 255;
        }
        uint8 *fourchan = dest;

@dennda
Copy link

dennda commented Sep 29, 2011

        uint8 *fourchan = (uint8*) malloc(sizeof(uint8) * width * height * 4);
        short cur;
        short *subscript = (short*) imgData;
        for (int i = 0; i < width * height; i++) {
            cur = subscript[i] + 1000;
            fourchan[i*4] = cur;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment