Created
August 6, 2010 14:26
-
-
Save pilotmoon/511388 to your computer and use it in GitHub Desktop.
This file contains 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
- (NSImage *)blankImageOfSize:(NSSize)size; | |
{ | |
NSBitmapImageRep *rep=[[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL | |
pixelsWide:size.width | |
pixelsHigh:size.height | |
bitsPerSample:8 | |
samplesPerPixel:4 | |
hasAlpha:YES | |
isPlanar:NO | |
colorSpaceName:NSDeviceRGBColorSpace | |
bytesPerRow:0 | |
bitsPerPixel:0]; | |
// blank the image | |
unsigned char *data=[rep bitmapData]; | |
NSUInteger count=[rep bytesPerPlane]; | |
memset(data, 0, count); | |
NSImage *img=[[NSImage alloc] initWithSize:size]; | |
[img addRepresentation:rep]; | |
return img; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment