Skip to content

Instantly share code, notes, and snippets.

@ChristianSch
Last active August 29, 2015 13:56
Show Gist options
  • Save ChristianSch/9294098 to your computer and use it in GitHub Desktop.
Save ChristianSch/9294098 to your computer and use it in GitHub Desktop.
// Größe
int viewHeight = 800;
int viewWidth = 800;
// Initialisieren des CGContext nach Dokumentation
int bitmapBytesPerRow = (pixelsWide * 4);
int bitmapByteCount = (bitmapBytesPerRow * pixelsHigh);
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
void *bitmapData = malloc( bitmapByteCount );
if (bitmapData == NULL)
NSLog(@"Memory not allocated!");
CGContextRef contextRef = CGBitmapContextCreate(bitmapData,
pixelsWide,
pixelsHigh,
8,
bitmapBytesPerRow,
colorSpace,
(CGBitmapInfo)kCGImageAlphaPremultipliedFirst);
if (contextRef == NULL)
{
free(bitmapData);
NSLog(@"Context could not be created!");
}
CGColorSpaceRelease(colorSpace);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment