Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of scodec
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