koher / swift-image

SwiftImage: an image library in Swift with Swifty APIs and value semantics
MIT License
529 stars 57 forks source link

All pixels are returned as transparent #58

Open Codeglee opened 3 years ago

Codeglee commented 3 years ago

Am I using this incorrectly? All pixels appear empty.

let image = UIImage(named: "01", in: .main, with: nil)!
let rgbaImage = SwiftImage.Image<RGBA<UInt8>>(uiImage: image)

(0..<rgbaImage.width).forEach { x in
    (0..<rgbaImage.height).forEach { y in

        guard let pixel = rgbaImage.pixelAt(x: x, y: y) else { return }
        // NOTE: pixel.red, green, blue and alpha are all 0 for every pixel
    }
}
Codeglee commented 3 years ago

The image is a png with transparency.