[英]Save image as is in photo album using swift
I've written a steganography application in Swift v2.我在 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.工作流程很简单:我打开一个图像,我输入一条消息进行保存,我执行 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?如何在不让 iOS 更改我的任何位的情况下将我的图像直接保存到相册? (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)
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!)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.