Created
August 9, 2009 08:23
-
-
Save richcollins/164662 to your computer and use it in GitHub Desktop.
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
- (void)setupTexture | |
{ | |
CGDataProviderRef provider = CGDataProviderCreateWithFilename([imagePath UTF8String]); | |
CGImageRef image = CGImageCreateWithPNGDataProvider(provider, NULL, true, kCGRenderingIntentDefault); | |
CGDataProviderRelease(provider); | |
size_t width = CGImageGetWidth(image); | |
size_t height = CGImageGetHeight(image); | |
realloc(textureData, width * height * 4); | |
CGContextRef textureContext = CGBitmapContextCreate(textureData, width, height, 8, width * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaPremultipliedLast); | |
CGContextDrawImage(textureContext, CGRectMake(0, 0, width, height), image); | |
CGImageRelease(image); | |
CGContextRelease(textureContext); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment