Reputation: 2489
I've written a steganography application in Swift v2. The workflow is simple : I open an image, I type in a message to save, I perform bitmanip to modify the least significant bit and then I save to photo album.
Problem is, iOS is running compression (I believe) on my image and some of the bits change.
How can I save my image directly to the photo album without having iOS change any of my bits? (I can post the code here, but there is a lot of it)
(this is a small snippet of the overall code)
let imageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: imageRef!)
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil)
Upvotes: 2
Views: 1065
Reputation: 2489
It seems that I just needed to convert my newImage to be a UIImagePNGRepresenation.
let imageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: imageRef!)
let newImagePNG = UIImagePNGRepresentation(newImage)
var saveableImage = UIImage(data: newImagePNG!)
saveImage(saveableImage!)
Upvotes: 2