Permalink
Browse files

v2.14.2 -- add GimpSlur

  • Loading branch information...
Sciss committed May 7, 2018
1 parent 68724f8 commit 49d27925274e001eef2309d18798f107c35fdd09
View
@@ -2,7 +2,7 @@ lazy val baseName = "FScape"
lazy val baseNameL = baseName.toLowerCase
lazy val githubRepo = "FScape-next"
-lazy val projectVersion = "2.14.2-SNAPSHOT"
+lazy val projectVersion = "2.14.2"
lazy val mimaVersion = "2.14.0"
lazy val baseDescription = "An audio rendering library"
@@ -35,8 +35,10 @@ lazy val deps = new {
val soundProcesses = "3.19.0"
}
val test = new {
+ val kollFlitz = "0.2.2"
val lucre = "3.7.0"
val scalaTest = "3.0.5"
+ val scopt = "3.7.0"
}
}
@@ -73,7 +75,9 @@ lazy val core = Project(id = s"$baseNameL-core", base = file("core"))
"de.sciss" %% "optional" % deps.main.optional,
"de.sciss" %% "scala-chart" % deps.main.scalaChart,
"com.typesafe.akka" %% "akka-stream" % deps.main.akka,
- "com.typesafe.akka" %% "akka-stream-testkit" % deps.main.akka
+ "com.typesafe.akka" %% "akka-stream-testkit" % deps.main.akka,
+ "com.github.scopt" %% "scopt" % deps.test.scopt % Test,
+ "de.sciss" %% "kollflitz" % deps.test.kollFlitz % Test
),
mimaPreviousArtifacts := Set("de.sciss" %% s"$baseNameL-core" % mimaVersion)
)
@@ -86,8 +90,8 @@ lazy val lucre = Project(id = s"$baseNameL-lucre", base = file("lucre"))
libraryDependencies ++= Seq(
"de.sciss" %% "soundprocesses-core" % deps.lucre.soundProcesses,
"de.sciss" %% "filecache-txn" % deps.lucre.fileCache,
- "org.scalatest" %% "scalatest" % deps.test.scalaTest % "test",
- "de.sciss" %% "lucre-bdb" % deps.test.lucre % "test"
+ "org.scalatest" %% "scalatest" % deps.test.scalaTest % Test,
+ "de.sciss" %% "lucre-bdb" % deps.test.lucre % Test
),
mimaPreviousArtifacts := Set("de.sciss" %% s"$baseNameL-lucre" % mimaVersion)
)
@@ -98,7 +102,7 @@ lazy val cdp = Project(id = s"$baseNameL-cdp", base = file("cdp"))
.settings(
description := "Bridge from FScape to Composers Desktop Project",
libraryDependencies ++= Seq(
- "org.scalatest" %% "scalatest" % deps.test.scalaTest % "test"
+ "org.scalatest" %% "scalatest" % deps.test.scalaTest % Test
)
// mimaPreviousArtifacts := Set("de.sciss" %% s"$baseNameL-cdp" % mimaVersion)
)
@@ -21,6 +21,9 @@ import scala.collection.immutable.{IndexedSeq => Vec}
/** A UGen similar to GIMP's Slur image filter. Instead of a hard-coded kernel,
* the probability table must be provided as a separate input.
+ * The kernel width and height should be odd, so that the kernel is considered to be
+ * symmetric around each input image's pixel. If they are odd, the centre corresponds to
+ * integer divisions `kernelWidth/2` and `kernelHeight/2`.
*
* @param in image input
* @param width image width
@@ -14,7 +14,9 @@
package de.sciss.fscape
package graph
+import de.sciss.file.File
import de.sciss.serial.{DataInput, DataOutput, ImmutableSerializer}
+import javax.imageio.ImageIO
import scala.annotation.switch
@@ -80,4 +82,31 @@ object ImageFile {
height : Int,
numChannels : Int,
quality : Int = 80)
-}
+
+ def readSpec(path: String): Spec = readSpec(new File(path))
+
+ /** Determines the spec of an image file.
+ * A bit of guess work is involved (not tested for float format).
+ * JPEG quality is currently _not_ determined.
+ */
+ def readSpec(f: File): Spec = {
+ val in = ImageIO.createImageInputStream(f)
+ val reader = ImageIO.getImageReaders(in).next()
+ try {
+ reader.setInput(in)
+ val fmt = reader.getFormatName
+ val w = reader.getWidth (0)
+ val h = reader.getHeight(0)
+ val s = reader.getImageTypes(0).next()
+ val nc = s.getNumComponents
+ val nb = s.getColorModel.getPixelSize / nc
+ // Ok, that's a guess, LOL
+ val st = if (nb == 8) SampleFormat.Int8 else if (nb == 16) SampleFormat.Int8 else SampleFormat.Float
+ val tpe = if (fmt.toLowerCase == "png") Type.PNG else Type.JPG
+ Spec(fileType = tpe, sampleFormat = st, width = w, height = h, numChannels = nc)
+
+ } finally {
+ reader.dispose() // XXX TODO --- do we also need to call `in.close()` ?
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 49d2792

Please sign in to comment.