Hi all,
I am struggling to create a CGImage (or an NSImage) out of the hb_get_preview data.
Could anybody enlighten me what kind of format the returned buffer have? I am really stuck
Regards
NikWest
hb_get_preview -> CGImage / NSImage how?
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.
*******************************
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.
*******************************
Solved
Ok, thanks.
I solved it. In case somebody is wondering how, here is the code snippet:
Problem was mostly because the buffer has a BGRA layout.
NikWest
I solved it. In case somebody is wondering how, here is the code snippet:
Code: Select all
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGContextRef cntxt = CGBitmapContextCreate(
[imageBuffer mutableBytes],
title->width+2,
title->height+2,
8,
(title->width+2)*4,
cs,
kCGImageAlphaNoneSkipFirst|kCGBitmapByteOrder32Little
);
hb_get_preview( handle, title, fPicture, [imageBuffer mutableBytes]);
CGImageRef image = CGBitmapContextCreateImage(cntxt);
CGContextRelease(cntxt);
CGColorSpaceRelease(cs);
NikWest