Hi there,
I’m using xCode11 with cocos2d 3.17. I have a iOS app to porting as a macOS app. I need help for the method take screenshot. this is the actual method on iOS app:
void BridgeIOS::takeScreenshot(unsigned char * img, ssize_t size, int width, int height) {
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(img,
width,
height,
8,
width * 4,
colorSpace,
kCGImageAlphaPremultipliedLast );
CGImageRef imageRef = CGBitmapContextCreateImage (ctx);
UIImage* rawImage = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
UIImageWriteToSavedPhotosAlbum(rawImage, nil, nil, nil);
CGColorSpaceRelease(colorSpace);
CGContextRelease(ctx);
}
For the porting I changed it like this:
void BridgeMac::takeScreenshot(unsigned char * img, ssize_t size, int width, int height) {
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
CGContextRef ctx = CGBitmapContextCreate(img,
width,
height,
8,
width * 4,
colorSpace,
kCGImageAlphaPremultipliedLast );
CGImageRef imageRef = CGBitmapContextCreateImage (ctx);
CIImage* rawImage = [CIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
UIImageWriteToSavedPhotosAlbum(rawImage, nil, nil, nil); //error in this line
CGColorSpaceRelease(colorSpace);
CGContextRelease(ctx);
}
There is a corresponding method for UIImageWriteToSavedPhotosAlbum but for iOS application? thank you if someone can answer me