import UIKit
let image = UIImage(named: "sample.png")
// Process the image!
var myRGBA = RGBAImage(image: image!)
let avgRed = 122
let avgGreen = 113
let avgBlue = 51
for y in 0..<myRGBA?.height {
for x in 0..<myRGBA?.width {
let index = y * (myRGBA?.width)! + x
var pixel = myRGBA?.pixels[index]
let redDiff = Int(pixel.red) - avgRed
if (redDiff>0)
{
pixel.red = UInt8( max(0, min(255,avgRed + redDiff * 5)))
myRGBA?.pixels[index] = pixel
}
}
}
let newImage2 = myRGBA?.toUIImage()
错误在于 - &gt;二元运算符'..&lt;'不能应用于'Int'和'Int?'
类型的操作数RGBAImage运行平稳,没有任何错误
我在swift 3中编写代码
答案 0 :(得分:0)
我认为你只需要打开你的选择
import UIKit
let image = UIImage(named: "sample.png")
// Process the image!
var myRGBA = RGBAImage(image: image!)
let avgRed = 122
let avgGreen = 113
let avgBlue = 51
if let unwrapped = myRGBA?{
for y in 0..< unwrapped.height {
for x in 0..< unwrapped.width {
let index = y * (myRGBA?.width)! + x
var pixel = myRGBA?.pixels[index]
let redDiff = Int(pixel.red) - avgRed
if (redDiff>0)
{
pixel.red = UInt8( max(0, min(255,avgRed + redDiff * 5)))
myRGBA?.pixels[index] = pixel
}
}
}
}
let newImage2 = myRGBA?.toUIImage()
答案 1 :(得分:0)
我改变了一些事情,现在下面的代码适合我
google.maps.event.clearInstanceListeners(window);
google.maps.event.clearInstanceListeners(document);
答案 2 :(得分:0)
错误原因:
Swift 3.0中默认不支持可选比较。
因此,如果要将代码迁移到Swift 3.0,则需要自己的重载比较运算符或快速迁移器将为您执行此操作。
重载方法如下所示:
library(data.table)
setDT(df)[, z := unlist(lapply(x, function(y) toString(grep(y, s, value = TRUE))))][z=="", z := x][]