Last active
April 2, 2017 18:06
-
-
Save yoavst/a4c744425c227ee4b34e to your computer and use it in GitHub Desktop.
Create survivor for codeguru from image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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