Skip to content

Instantly share code, notes, and snippets.

@yoavst
Last active April 2, 2017 18:06
Show Gist options
  • Save yoavst/a4c744425c227ee4b34e to your computer and use it in GitHub Desktop.
Save yoavst/a4c744425c227ee4b34e to your computer and use it in GitHub Desktop.
Create survivor for codeguru from image
package com.yoavst.bgonen
import java.io.File
import javax.imageio.ImageIO
fun main(args: Array<String>) {
val image = ImageIO.read(File("""IMAGE_PATH"""))
val w = image.width
val h = image.height
val array = Array(w) { IntArray(h) }
val raster = image.data
repeat(w) { j ->
repeat(h) { k ->
array[j][k] = raster.getSample(j, k, 0)
}
}
val file = File("""FILE_PATH\output.txt""")
repeat(w) { j ->
repeat(h) { k ->
if (array[j][k] == 0) {
file.appendText("mov [byte ptr ${k*256+j}], al\n")
}
}
}
print("finished!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment