如何保存编辑后的图像?

发布于 2024-12-01 02:24:49 字数 79 浏览 2 评论 0原文

我有 UIImagePicker 来选择图像。选择图像后,我正在编辑它,现在我想保存该图像。

谁能告诉我如何将图像保存到相册中?

I have UIImagePicker to select the image. After selecting the image I am editing it and now I want to save that image.

Can anyone please tell me how can I save the image to Photo Album?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

许久 2024-12-08 02:24:49

看看这个教程

http://iosdevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html

这是我的代码获取图像如果图像被编辑,则编辑后的图像将被考虑在内。

如果未编辑,则将拍摄原始图像

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

UIImage *image;

if (picker.editing == YES) {

        image = [info objectForKey:@"UIImagePickerControllerEditedImage"];  

}
else {
        image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

    //  [picker release];

    //  [self dismissModalViewControllerAnimated:YES];
}

take a look at this tutorial

http://iosdevelopertips.com/camera/camera-application-to-take-pictures-and-save-images-to-photo-album.html

here is my code to get image if the image is edited then edited image will be taken into account.

if not edited then original image will be taken

-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

UIImage *image;

if (picker.editing == YES) {

        image = [info objectForKey:@"UIImagePickerControllerEditedImage"];  

}
else {
        image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

    //  [picker release];

    //  [self dismissModalViewControllerAnimated:YES];
}
如果没有 2024-12-08 02:24:49

您可以使用此功能

UIImageWriteToSavedPhotosAlbum(UIImage *yourImage, id completionTarget, SEL completionSelector, void *contextInfo);

查看此问题的答案。 ..还有关于completionTarget 和completionSelector,来自文档...

completionTarget、completionSelector 和 contextInfo 的使用
参数是可选的,并且仅当您希望收到通知时才需要
当函数完成将图像写入到时异步
用户的相机胶卷或保存的照片相册。如果你不想成为
通知后,为这些参数传递 nil。

You can use this function

UIImageWriteToSavedPhotosAlbum(UIImage *yourImage, id completionTarget, SEL completionSelector, void *contextInfo);

See the answer to this question...And about completionTarget and completionSelector, from documentation...

The use of the completionTarget, completionSelector, and contextInfo
parameters is optional and necessary only if you want to be notified
asynchronously when the function finishes writing the image to the
user’s Camera Roll or Saved Photos album. If you do not want to be
notified, pass nil for these parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文