|
@@ -3,14 +3,16 @@ package resize
|
|
|
import (
|
|
import (
|
|
|
"image"
|
|
"image"
|
|
|
"image/color"
|
|
"image/color"
|
|
|
- "runtime"
|
|
|
|
|
|
|
+ "image/png"
|
|
|
|
|
+ "os"
|
|
|
|
|
+ //"runtime"
|
|
|
"testing"
|
|
"testing"
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
var img = image.NewGray16(image.Rect(0, 0, 3, 3))
|
|
var img = image.NewGray16(image.Rect(0, 0, 3, 3))
|
|
|
|
|
|
|
|
func init() {
|
|
func init() {
|
|
|
- runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
|
|
|
|
+ //runtime.GOMAXPROCS(runtime.NumCPU())
|
|
|
img.Set(1, 1, color.White)
|
|
img.Set(1, 1, color.White)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -64,6 +66,12 @@ func Test_SameColor(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+func Test_Bounds(t *testing.T) {
|
|
|
|
|
+ img := image.NewRGBA(image.Rect(20, 10, 200, 99))
|
|
|
|
|
+ out := Resize(80, 80, img, Lanczos2)
|
|
|
|
|
+ out.At(0, 0)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
func Benchmark_BigResizeLanczos3(b *testing.B) {
|
|
func Benchmark_BigResizeLanczos3(b *testing.B) {
|
|
|
var m image.Image
|
|
var m image.Image
|
|
|
for i := 0; i < b.N; i++ {
|
|
for i := 0; i < b.N; i++ {
|
|
@@ -117,3 +125,21 @@ func Benchmark_LargeJpegThumbLanczos2(b *testing.B) {
|
|
|
func Benchmark_LargeJpegThumbLanczos3(b *testing.B) {
|
|
func Benchmark_LargeJpegThumbLanczos3(b *testing.B) {
|
|
|
jpegThumb(b, Lanczos3)
|
|
jpegThumb(b, Lanczos3)
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+func Benchmark_LargeN(b *testing.B) {
|
|
|
|
|
+ file, _ := os.Open("M94A0467.png")
|
|
|
|
|
+ defer file.Close()
|
|
|
|
|
+ img, _ := png.Decode(file)
|
|
|
|
|
+ var output image.Image
|
|
|
|
|
+
|
|
|
|
|
+ b.ResetTimer()
|
|
|
|
|
+ for i := 0; i < b.N; i++ {
|
|
|
|
|
+ output = Resize(900, 0, img, Bicubic)
|
|
|
|
|
+ }
|
|
|
|
|
+ b.StopTimer()
|
|
|
|
|
+
|
|
|
|
|
+ output.At(0, 0)
|
|
|
|
|
+ outPng, _ := os.Create("out.png")
|
|
|
|
|
+ defer outPng.Close()
|
|
|
|
|
+ png.Encode(outPng, output)
|
|
|
|
|
+}
|