Type of expression is ambiguous without more context error message when I try to blend two images

56 Views Asked by At

I'm trying to blend two same size images using code below but "filteredImage.image?.draw(in: areaSize, blendMode: .normal, alpha: opa)" this code will show error message says "Type of expression is ambiguous without more context".. What is wrong?

        let originalWidth:CGFloat  = originalImageView.frame.size.width
        let originalHeight:CGFloat = originalImageView.frame.size.height
        var opa = intensity * 0.01

        let size = CGSize(width: originalWidth, height: originalHeight)

        UIGraphicsBeginImageContext(size)

        let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height)
        let blendImageSize = areaSize

        originalImageView.image?.draw(in: areaSize, blendMode: .normal, alpha: 1.0)

        filteredImageView.image?.draw(in: areaSize, blendMode: .normal, alpha: opa)

        originalImageView.image = UIGraphicsGetImageFromCurrentImageContext()

        UIGraphicsEndImageContext()
1

There are 1 best solutions below

0
On BEST ANSWER

Change

alpha: opa

To

alpha: CGFloat(opa)