【问题标题】:Preserving alpha issues with loaded UIImages - how to avoid discarding alpha values on import?保留加载的 UIImages 的 alpha 问题 - 如何避免在导入时丢弃 alpha 值?
【发布时间】:2010-05-06 23:01:35
【问题描述】:

我的应用程序允许用户将带有 alpha 值的图像保存/加载到设备上的相机胶卷中。我可以在照片应用程序中看到这些图像是适当的 alpha'd,因为 alpha'd 区域只是显示为黑色。但是,当我使用来自(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)infoinfo 字典中的valueForKey:UIImagePickerControllerOriginalImage 消息将这些图像加载回应用程序时,alpha 值将变为白色,使这些部分变得不透明。有没有办法保留这些 alpha 值?

【问题讨论】:

    标签: iphone-sdk-3.0 uiimageview uiimage alpha alphablending


    【解决方案1】:

    发现了!这是我这样做的功能。您的里程可能会有所不同!:

    - (UIImage*)processImage:(UIImage*)image
    {
        CGImageRef reference = image.CGImage;
        float colors[6] = {0xEE, 0xFF, 0xEE, 0xFF, 0xEE, 0xFF};
        CGImageRef newimage = CGImageCreateWithMaskingColors(reference, colors);
        UIImage *result = [[UIImage alloc] initWithCGImage:newimage];
        CGImageRelease(newimage);
        return result;
    }
    

    【讨论】:

    • 非常感谢!这正是我想要的。
    【解决方案2】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-27
    • 2010-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多