CGColorSpace Reference
- int ImageWidth = 512;
- int ImageHeight = 512;
- unsigned char* pBuffer = NULL;
- CGContextRef CreateBitmapContext ()
- {
- CGContextRef pContext = NULL;
- CGColorSpaceRef ColorSpace = CGColorSpaceCreateDeviceRGB ();
- int bitmapByteCount = ( ImageWidth * 4 );
- int bitmapBytesPerRow = ( bitmapBytesPerRow * ImageWidth );
- pBuffer = new unsigned char [ bitmapByteCount ];
- if ( NULL == pBuffer )
- {
- delete [] pBuffer;
- CGColorSpaceRelease ( ColorSpace );
- return NULL;
- }
- pContext = CGBitmapContextCreate (
- pBuffer,
- ImageWidth,
- ImageHeight,
- 8,
- bitmapBytesPerRow,
- ColorSpace,
- kCGImageAlphaPremultipliedLast );
- if ( NULL == pContext )
- {
- delete [] m_pBuffer;
- CGColorSpaceRelease( colorSpace );
- return NULL;
- }
- CGColorSpaceRelease ( ColorSpace );
- return pContext;
- }
Комментариев нет:
Отправить комментарий