Save an Image to the iOS Photo Album/Camera Roll?

If I have an Image, I can use the PNGImageFormat class to write it as a File in some directory. Is there some similar way to use JUCE to save it to the iOS Photo Album/Camera Roll instead?

I found a solution in this old thread

A quick modification of one of the old functions yields this

[code]void saveToPhotosAlbum (const Image& imageToSave) {
JPEGImageFormat jpgff;
MemoryOutputStream mos;
jpgff.writeImageToStream (imageToSave, mos);

UIImage* im = [UIImage imageWithData: [NSData dataWithBytes: mos.getData() length: mos.getDataSize()]];
im = [UIImage imageWithCGImage: im.CGImage scale: 1.0f orientation: UIImageOrientationUp];
UIImageWriteToSavedPhotosAlbum (im, nil, nil, nil);


I’m not sure if that “scale: 1.0f” should actually be “scale: Desktop::getInstance().getDisplays().getMainDisplay().scale” or something, but at any rate it works well enough so far.