Skip to content

Instantly share code, notes, and snippets.

@DineshSolanki
Created October 7, 2020 16:13
Show Gist options
  • Save DineshSolanki/085b519ae1ac23ea54b4068814855339 to your computer and use it in GitHub Desktop.
Save DineshSolanki/085b519ae1ac23ea54b4068814855339 to your computer and use it in GitHub Desktop.
Kotlin BufferedImage extension function to transpose image.
fun BufferedImage.getTransposed(): BufferedImage {
val transposeImage = BufferedImage(this.height, this.width, BufferedImage.TYPE_INT_RGB)
repeat(transposeImage.width) { w ->
repeat(transposeImage.height) { h ->
transposeImage.setRGB(w, h, this.getRGB(h, w))
}
}
return transposeImage
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment