Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (CGContextRef) RFS_blackAndWhiteImageContextOfWidth:(int)pixelsWidth andHeight:(int)pixelsHeight
  2. {
  3.     CGContextRef theContext=NULL;
  4.     CGColorSpaceRef colorSpace;
  5.     void *bitmapData;
  6.     int bitmapByteCount;
  7.     int bitmapBytePerRow;
  8.    
  9.     bitmapBytePerRow = pixelsWidth;
  10.     bitmapByteCount = (bitmapBytePerRow * pixelsHeight);
  11.    
  12.     colorSpace = CGColorSpaceCreateDeviceGray();
  13.     bitmapData = malloc(bitmapByteCount);
  14.    
  15.     if(bitmapData == NULL) {
  16.         printf("Error");
  17.         return NULL;
  18.     }
  19.    
  20.     theContext = CGBitmapContextCreate(bitmapData,
  21.                                        pixelsWidth,
  22.                                        pixelsHeight,
  23.                                        8,
  24.                                        bitmapBytePerRow,
  25.                                        colorSpace,
  26.                                        kCGImageAlphaNoneSkipLast);
  27.    
  28.     if(theContext == NULL) {
  29.         free(bitmapData);
  30.         printf("ERROR");
  31.         return NULL;
  32.     }
  33. }
  34.  
  35. // get error: CGBitmapContextCreate: unsupported parameter combination: 8 integer bits/component; 16 bits/pixel; 1-component color space; kCGImageAlphaNoneSkipLast; 320 bytes/row.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement