First Scala

1 July 2017 ยท 1 minute read

Today I wrote first program on Scala.

It’s very simple filter which makes mirror image horizontally or/and vertically.

for (x <- 0 until w)
    for (y <- 0 until h) {
        val wOut = if (ox) w - x - 1 else x
        val hOut = if (oy) h - y - 1 else y
        out.setRGB(x, y, img.getRGB(wOut, hOut) & 0xffffff)
    }

When I wrote with program I use article about image processing in Scala.

Scala program compile to JVM bytecodes. Scala code use Java libraries. And in program I use java.io.File for opening files, javax.imageio.ImageIO for saving image to file and java.awt.image.BufferedImage for processing image.

I really liked it.

comments powered by Disqus
github