【问题标题】:How to save image after edit in iphone sdk?如何在 iphone sdk 中编辑后保存图像?
【发布时间】:2013-01-05 14:49:21
【问题描述】:

我想将旋转后的图像保存到照片库。我有一个 UIImageView 显示图像。我使用下面的 sn-p 来翻转图像。由于我转换了图像视图,旋转的图像确实会显示出来。但是在保存图像时,我得到了原始图像(未翻转)。如何保存翻转的图像?

CGAffineTransform transform =  CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(degrees));
   image.transform = transform;

【问题讨论】:

  • 山木你好,你有这个问题的解决方案吗?我也有同样的问题,请多多指教。

标签: iphone


【解决方案1】:

只需截取图像或保存它的视图的屏幕截图,无论它已被旋转还是翻转,它都会被保存下来......这里提供了一些代码......

-(IBAction)saveToPhotoGallery:(id)sender
{
    UIGraphicsBeginImageContext(baseView.frame.size);
    [baseView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *attachimage = [[UIImage alloc]initWithData:Data];
    UIImage *viImage=UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    attachimage = viImage;
    UIImageWriteToSavedPhotosAlbum(viImage, nil, nil, nil);

    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Save" message:@"Saved to photo gallery" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil,nil];
    [alert show];
}
}

希望这会有所帮助!!!

【讨论】:

  • 只有原始图像被保存到照片库而不是旋转图像
猜你喜欢
  • 2013-02-28
  • 2023-03-30
  • 2011-11-01
  • 1970-01-01
  • 2011-10-16
  • 1970-01-01
  • 2011-11-02
  • 1970-01-01
  • 2013-03-17
相关资源
最近更新 更多