chi
11/22/2017, 11:48 AMval bufferedImgFile: BufferedImage = ImageIO.read(File(filePath))
val imageMatrix: Array<IntArray> = Array(height) { IntArray(width) }
(0..(bufferedImgFile.height - 1)).map { hgt ->
(0..(bufferedImgFile.width - 1)).map { wdt ->
imageMatrix[hgt][wdt] = bufferedImgFile.getRGB(hgt, wdt)
}
}
And
val bufferedImgFile: BufferedImage = ImageIO.read(File(filePath))
val imageMatrix: Array<IntArray> = Array(height) { IntArray(width) }
async {
(0..(bufferedImgFile.height - 1)).map { hgt ->
async {
(0..(bufferedImgFile.width - 1)).map { wdt ->
data[hgt][wdt]= bufferedImgFile.getRGB(hgt, wdt)
}
}
}
}
The former would crash with an ArrayOutOfBoundsException
, the later doesn't crash and completes. Please why is this so?Andreas Sinz
11/22/2017, 12:04 PMasync
function come from? Anko? Coroutines?chi
11/22/2017, 12:04 PMAndreas Sinz
11/22/2017, 12:18 PMasync
catches Exceptions and puts it into the returned Deferred
Andreas Sinz
11/22/2017, 12:18 PMasync { ... }.await()
the same exception should be thrownchi
11/22/2017, 12:42 PMBufferedImage.getRGB
it says the An ArrayOutOfBoundsException may be thrown if the coordinates are not in bounds
GIven the dimensions, am I supposed to be getting this error?Andreas Sinz
11/22/2017, 12:55 PMgetRGB(x: Int, y: Int)
, so it expects the horizontal coordinate as the first parameter, you flipped themchi
11/22/2017, 1:21 PMphilipharder
11/30/2017, 9:00 PMchi
12/01/2017, 5:19 AMimageMatrix[hgt][wdt]= bufferedImgFile.getRGB(hgt, wdt)