-
-
Save Maksim-Zhuravlev/29238c547bd4f5eed1d1d392d9845abe to your computer and use it in GitHub Desktop.
Example of scodec
This file contains 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 GIFReader | |
import scodec._ | |
import bits._ | |
import codecs._ | |
import java.nio.file.{Files, Paths} | |
case class GIFHeader(width : Int, height : Int) | |
/** | |
* Created by maxim on 17.04.2016. | |
*/ | |
class Decoder(path : String) { | |
val byteArray = Files.readAllBytes(Paths.get(path)) | |
val bitVector = BitVector(byteArray) | |
val headerCodec = (constant(hex"474946383961".bits) :: uint16L :: uint16L).as[GIFHeader] //GIF89a | |
val decoded = headerCodec.decode(bitVector) | |
println(decoded.require.value) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment