geotrellis.raster.render.ImageFormats.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of geotrellis-raster_2.11 Show documentation
Show all versions of geotrellis-raster_2.11 Show documentation
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