diff app/src/main/java/com/bartsent/simpleresizer/lib/Resizer.kt @ 17:86740f593b6c

Better memoization, more rational API.
author David Barts <n5jrn@me.com>
date Sun, 21 Feb 2021 22:14:07 -0800
parents b1605be35bcc
children eedf995462d9
line wrap: on
line diff
--- a/app/src/main/java/com/bartsent/simpleresizer/lib/Resizer.kt	Sun Feb 21 21:43:54 2021 -0800
+++ b/app/src/main/java/com/bartsent/simpleresizer/lib/Resizer.kt	Sun Feb 21 22:14:07 2021 -0800
@@ -117,15 +117,13 @@
         }
     }
 
-    private val DEFAULT_KERNEL = LanczosKernel()
-
     /**
      * Resize the horizontal aspect.
      * @param       newWidth    Width of new image
      * @param       kernel      Scaling kernel to use (default: LanczosKernel)
      * @return                  A new Resizer object, resampled per specifications
      */
-    fun horizontal(newWidth: Int, kernel: ScalingKernel = DEFAULT_KERNEL): Resizer {
+    fun horizontal(newWidth: Int, kernel: ScalingKernel): Resizer {
         val dst = Resizer(newWidth, height)
         val weights = precomputeWeights(newWidth, width, kernel)
         for (y in 0 until height) {
@@ -140,7 +138,7 @@
      * @param       kernel      Scaling kernel to use (default: LanczosKernel)
      * @return                  A new Resizer object, resampled per specifications
      */
-    fun vertical(newHeight: Int, kernel: ScalingKernel = DEFAULT_KERNEL): Resizer {
+    fun vertical(newHeight: Int, kernel: ScalingKernel): Resizer {
         val dst = Resizer(width, newHeight)
         val weights = precomputeWeights(newHeight, height, kernel)
         for (x in 0 until width) {