【问题标题】:I want to get/set RGBA values of pixels in a UiImage in swift?我想快速获取/设置 UiImage 中像素的 RGBA 值?
【发布时间】:2017-11-27 12:00:08
【问题描述】:

我只能找到可以获取像素的旧帖子。 (CGImage -> CFData -> UInt8 -> RGBA)
这种方法只能获取像素值。

我想获取和设置 UIImage 或像素缓冲区的像素值。

是否有任何简单或抽象的函数/库可以做到这一点?

【问题讨论】:

    标签: ios swift image-processing uiimage uikit


    【解决方案1】:
     let yourImageView: UIImageView = {
        let image = UIImage(named: "yourimage")
        let imageView = UIImageView(image: image)
        imageView.backgroundColor = UIColor.rgb(red: 252, green: 192, blue: 46)
        return imageView
    
    }()
    

    //你仍然可以在外面设置它 yourImageView.backgroundColor = UIColor.rgb(red: 252, green: 192, blue: 46)

    我希望这会有所帮助?

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-28
    • 1970-01-01
    • 1970-01-01
    • 2016-10-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-24
    相关资源
    最近更新 更多