Search code examples
facebooksocial-frameworkcgimageref

how to share CGImageRef to facebook using social library?


This is the method that have the image data, that image will than write to camera roll

CGImageRef cgImageResult = [self newSquareOverlayedImageForFeatures:features
                                                                                       inCGImage:srcImage 
                                                                                 withOrientation:curDeviceOrientation 
                                                                                                                 frontFacing:isUsingFrontFacingCamera];

                                  if (srcImage)
                            CFRelease(srcImage);

                        CFDictionaryRef attachments = CMCopyDictionaryOfAttachments(kCFAllocatorDefault, 
                                                                                    imageDataSampleBuffer, 
                                                                                    kCMAttachmentMode_ShouldPropagate);
                        [self writeCGImageToCameraRoll:cgImageResult withMetadata:(id)attachments];

Solution

  • Convert the CGImage to UIImage like so: UIImage *image = [UIImage imageWithCGImage:<#(CGImageRef)#>]; and post it to facebook as you have mentioned on your comments. Good Luck!

    EDIT Okay, do it like this:

    UIImage *image = [UIImage imageWithCGImage:cgImageResult];
    [fbController addImage:image];