Javaのコードはあったが、Kotlinはあまり無いようだったので、メモ
fun Bitmap.filter(): Bitmap {
val pixels = IntArray(width * height)
getPixels(pixels, 0, width, 0, 0, width, height)
for (y in 0 until height) {
for (x in 0 until width) {
//ここでピクセル操作(この場合は色反転を行っている)
pixels[x + y * width] = pixels[x + y * width] xor 0x00ffffff
}
}
return copy(Bitmap.Config.ARGB_8888, true).apply {
setPixels(pixels, 0, width, 0, 0, width, height)
}
}
関連記事