Skip to content

Instantly share code, notes, and snippets.

@ponkotuy
Last active August 29, 2015 14:23
Show Gist options
  • Save ponkotuy/da7855e21d7cbb5406b9 to your computer and use it in GitHub Desktop.
Save ponkotuy/da7855e21d7cbb5406b9 to your computer and use it in GitHub Desktop.
jpexsのffdecで艦これの海域Flashから地図データぶっこ抜く
import java.io._
import com.jpexs.decompiler.flash.SWF
import com.jpexs.decompiler.flash.tags.{ShowFrameTag, PlaceObject2Tag, DefineSpriteTag, DefineBitsJPEG3Tag}
import scala.collection.JavaConverters._
object Main {
val LineRegex = """line(\d)""".r
def main(args: Array[String]) {
val path = "/home/yosuke/01_01.swf"
val is = new FileInputStream(new File(path))
val swf = new SWF(is, path, "KanColle1_1", false)
val ids = swf.getCharacters.asScala
ids.collect {
case (i, jpeg: DefineBitsJPEG3Tag) =>
val os = new FileOutputStream(s"/home/yosuke/${jpeg.getCharacterId}.jpg")
output(jpeg.getImageData, os)
case (i, sprite: DefineSpriteTag) =>
val subtags = sprite.getSubTags.asScala
val isTarget = subtags.collectFirst {
case frame: ShowFrameTag => true
}.isDefined
if(isTarget) {
subtags.collect {
case obj: PlaceObject2Tag =>
for {
name <- Option(obj.name)
matcher <- LineRegex.findFirstMatchIn(name)
} {
println(matcher.group(1).toInt, obj.matrix.translateX, obj.matrix.translateY)
}
}
}
}
}
val BufSize = 1024 * 4
def output(is: InputStream, os: OutputStream): Unit = {
val buf = new Array[Byte](BufSize)
while(is.read(buf) >= 0) {
os.write(buf)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment