【问题标题】:Not able to merge two images into one无法将两张图片合并为一张
【发布时间】:2013-03-30 02:07:04
【问题描述】:

我正在尝试将两张图片合二为一,然后将该图片保存到相机胶卷上。但它只是显示一个空白图像。有人可以帮忙吗?

我的代码:

-(void)SaveFinalImage{    
    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *savedImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(savedImg, nil, nil, nil);     
}

【问题讨论】:

    标签: iphone ios objective-c xcode image


    【解决方案1】:

    我在我的应用程序中使用了它。

    UIImage *bottomImage = [UIImage imageNamed:@"bottom.png"]; //background image
    UIImage *image       = [UIImage imageNamed:@"top.png"]; //foreground image
    
    CGSize newSize = CGSizeMake(width, height);
    UIGraphicsBeginImageContext( newSize );
    
    // Use existing opacity as is
    [bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
    
    // Apply supplied opacity if applicable
    [image drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:0.8];
    
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    
    UIGraphicsEndImageContext();
    

    有关更多信息,请参阅我在同一主题上的相关答案。 iOS - Merging two images of different size

    【讨论】:

      猜你喜欢
      • 2011-11-04
      • 2022-01-19
      • 1970-01-01
      • 2016-03-31
      • 2021-08-18
      • 2011-10-31
      • 1970-01-01
      相关资源
      最近更新 更多