Skip to content

Instantly share code, notes, and snippets.

@rothomp3
Created June 6, 2014 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rothomp3/d8354ec10d0b6597cf50 to your computer and use it in GitHub Desktop.
Save rothomp3/d8354ec10d0b6597cf50 to your computer and use it in GitHub Desktop.
Objective-C way of writing to a memory buffer
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