commit 9d9b98fa4a1778d334c77043cd22aa42de14469e
parent 282cb9c7f4ab20abeeccda1c3498596f98a28a28
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date: Mon, 29 Jan 2018 19:31:04 +0100
[*] Renamed file for clarity.
Diffstat:
1 file changed, 44 insertions(+), 0 deletions(-)
diff --git a/interpolation.go b/interpolation.go
@@ -0,0 +1,44 @@
+package icns
+
+import (
+ "image"
+ "io"
+
+ "github.com/nfnt/resize"
+)
+
+// InterpolationFunction is the algorithm used to resize the image.
+type InterpolationFunction = resize.InterpolationFunction
+
+// InterpolationFunction constants.
+const (
+ // Nearest-neighbor interpolation
+ NearestNeighbor InterpolationFunction = iota
+ // Bilinear interpolation
+ Bilinear
+ // Bicubic interpolation (with cubic hermite spline)
+ Bicubic
+ // Mitchell-Netravali interpolation
+ MitchellNetravali
+ // Lanczos interpolation (a=2)
+ Lanczos2
+ // Lanczos interpolation (a=3)
+ Lanczos3
+)
+
+// EncodeWithInterpolationFunction uses the given interpolation function resize
+// the image before writing out to wr.
+func EncodeWithInterpolationFunction(
+ wr io.Writer,
+ img image.Image,
+ interp InterpolationFunction,
+) error {
+ iconset, err := NewIconSet(img, interp)
+ if err != nil {
+ return err
+ }
+ if _, err := iconset.WriteTo(wr); err != nil {
+ return err
+ }
+ return nil
+}