Created
June 6, 2014 14:07
-
-
Save rothomp3/d8354ec10d0b6597cf50 to your computer and use it in GitHub Desktop.
Objective-C way of writing to a memory buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint8_t* bitmapBuffer = calloc(width * height * 4, sizeof(uint8_t)); | |
int pixelNumber = (x * 4) + (y * width * 4); | |
bitmapBuffer[pixelNumber + 3] = 255; // alpha | |
bitmapBuffer[pixelNumber + 2] = redValue; | |
bitmapBuffer[pixelNumber + 1] = greenValue; | |
bitmapBuffer[pixelNumber + 0] = blueValue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment