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.
我在Swift v2中编写了一个隐写应用程序。工作流程很简单:打开一个图像,输入要保存的消息,执行bitmanip以修改最不重要的位,然后保存到相册。
Problem is, iOS is running compression (I believe) on my image and some of the bits change.
问题是,iOS正在我的图像上运行压缩(我相信),一些位元发生了变化。
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)
如何将我的图像直接保存到相册中,而不让iOS更改我的任何位元?(我可以在这里发布代码,但是有很多)
(this is a small snippet of the overall code)
(这是整个代码的一小部分)
let imageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: imageRef!)
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil)
1 个解决方案
#1
2
It seems that I just needed to convert my newImage to be a UIImagePNGRepresenation.
看起来我只是需要将我的newImage转换成UIImagePNGRepresenation。
let imageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: imageRef!)
let newImagePNG = UIImagePNGRepresentation(newImage)
var saveableImage = UIImage(data: newImagePNG!)
saveImage(saveableImage!)
#1
2
It seems that I just needed to convert my newImage to be a UIImagePNGRepresenation.
看起来我只是需要将我的newImage转换成UIImagePNGRepresenation。
let imageRef = CGBitmapContextCreateImage(context);
let newImage = UIImage(CGImage: imageRef!)
let newImagePNG = UIImagePNGRepresentation(newImage)
var saveableImage = UIImage(data: newImagePNG!)
saveImage(saveableImage!)