Github user viirya commented on a diff in the pull request:
https://github.com/apache/spark/pull/20389#discussion_r163756853
--- Diff: mllib/src/main/scala/org/apache/spark/ml/image/ImageSchema.scala
---
@@ -169,8 +169,7 @@ object ImageSchema {
var offset = 0
for (h <- 0 until height) {
for (w <- 0 until width) {
- val color = new Color(img.getRGB(w, h))
-
+ val color = new Color(img.getRGB(w, h), nChannels == 4)
decoded(offset) = color.getBlue.toByte
decoded(offset + 1) = color.getGreen.toByte
decoded(offset + 2) = color.getRed.toByte
--- End diff --
At line 177,
```scala
if (nChannels == 4) {
decoded(offset + 3) = color.getAlpha.toByte
}
```
We can directly use `hasAlpha` too, instead of indirectly comparing
`nChannels`.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]