All Downloads are FREE. Search and download functionalities are using the official Maven repository.

geotrellis.raster.render.ImageFormats.scala Maven / Gradle / Ivy

Go to download

GeoTrellis is an open source geographic data processing engine for high performance applications.

The newest version!
package geotrellis.raster.render

import java.io.{FileOutputStream, File}

sealed trait ImageFormat

case class Jpg(bytes: Array[Byte]) extends ImageFormat {
  def write(path: String):Unit  = {
    val fos = new FileOutputStream(new File(path))
    try {
      fos.write(bytes)
    } finally {
      fos.close
    }
  }
}

case class Png(bytes: Array[Byte]) extends ImageFormat {
  def write(path: String):Unit  = {
    val fos = new FileOutputStream(new File(path))
    try {
      fos.write(bytes)
    } finally {
      fos.close
    }
  }
}

object Jpg {
  implicit def jpgToArrayByte(jpg: Jpg): Array[Byte] =
    jpg.bytes

  implicit def arrayByteToJpg(arr: Array[Byte]): Jpg =
    Jpg(arr)
}

object Png {
  implicit def pngToArrayByte(png: Png): Array[Byte] =
    png.bytes

  implicit def arrayByteToPng(arr: Array[Byte]): Png =
    Png(arr)
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy