Skip to content

Instantly share code, notes, and snippets.

@EverythingSolution
Created September 6, 2011 00:57
Show Gist options
  • Save EverythingSolution/1196284 to your computer and use it in GitHub Desktop.
Save EverythingSolution/1196284 to your computer and use it in GitHub Desktop.
5 bits per pixel, no alpha
static const CGBitmapInfo kDefault16CGBitmapInfoNoAlpha = (kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder16Host);
CGContextRef CreateCGBitmapContextForWidthAndHeight(void *data, unsigned int width, unsigned int height)
{
CGColorSpaceRef colorSpace = GetDeviceRGBColorSpace(); // function to get static color space instance
CGBitmapInfo alphaInfo = kDefault16CGBitmapInfoNoAlpha;
return CGBitmapContextCreate(
data,
width,
height,
5, /* Bits per component */
width*2, /* Bytes per row (3 components per pixel, 5 bits per component, 15 bits per pixel (round up to 16), 2 bytes per pixel) */
colorSpace,
alphaInfo
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment