相关疑难解决方法(0)

根据顶部图像的alpha /透明度混合两个uiimages

我正在尝试将背景与前景图像混合,其中前景图像是带有线条的透明图像.

我试图这样做.

UIGraphicsBeginImageContext(CGSizeMake(320, 480));
CGContextRef context = UIGraphicsGetCurrentContext();   

// create rect that fills screen
CGRect bounds = CGRectMake( 0,0, 320, 480);

// This is my bkgnd image
CGContextDrawImage(context, bounds, [UIImage imageNamed:@"bkgnd.jpg"].CGImage);

CGContextSetBlendMode(context, kCGBlendModeSourceIn);

// This is my image to blend in
CGContextDrawImage(context, bounds, [UIImage imageNamed:@"over.png"].CGImage);

UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext();

UIImageWriteToSavedPhotosAlbum(outputImage, self, nil, nil);
// clean up drawing environment
//
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

但似乎没有用.

任何建议将不胜感激.

iphone alphablending

32
推荐指数
4
解决办法
5万
查看次数

标签 统计

alphablending ×1

iphone ×1