Code: Select all
CGColorSpaceRef color = CGColorSpaceCreateDeviceGray();
if ([data pixelDataType] == ICScannerPixelDataTypeRGB) color = CGColorSpaceCreateDeviceRGB();
CGDataProviderRef provider = CGDataProviderCreateWithCFData(CFDataCreate(NULL, [[data dataBuffer] bytes], [data dataSize]));
CGImageRef image = CGImageCreate([data fullImageWidth], [data fullImageHeight], [data bitsPerComponent], [data bitsPerPixel],
[data bytesPerRow], color, kCGBitmapByteOrderDefault|kCGImageAlphaNone, provider, NULL, false, kCGRenderingIntentDefault);
NSImage *finImage = [[NSImage alloc] initWithCGImage:image size:NSMakeSize([data fullImageWidth], [data fullImageHeight])];
CGImageRelease(image);
CGDataProviderRelease(provider);
CGColorSpaceRelease(color);
- dataSize
- dataBuffer
- bitsPerPixel
- bytesPerRow
- pixelDataType
- fullImageWidth
- fullImageHeight
- bitsPerComponent
There was a similar example by wilbert, in this post, which created a PureBasic-usable image from an NSImage which was created from a CGImage, but in that example, the source image was returned from a screen capture function instead of being created from raw data.
Would it be possible to duplicate the above code in PureBasic, and to create a PureBasic-usable image from the raw data?
Or better still, would it be possible to use the raw data with PureBasic's native image functions to create an image?
Thanks in advance.