diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44b578a --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +child_porn +imageutils.test +cpu.out diff --git a/go.mod b/go.mod index d945a00..29245e7 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/potassium5703/imageutils -go 1.21.4 +go 1.22.6 + +require github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2a7a0cd --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0 h1:sowjIIVme5ovcdB0kjP3w+4xbVNrlOPdx7Up4LIGJz8= +github.com/potassium5703/texture v0.0.0-20240820054037-fce43fc4b0f0/go.mod h1:KwM7hMpZhr3XySWuK/SZ7s1BXVQe8p1IyZftYg9KtWY= diff --git a/scale_test.go b/scale_test.go new file mode 100644 index 0000000..0ff66d6 --- /dev/null +++ b/scale_test.go @@ -0,0 +1,33 @@ +package imageutils + +import ( + "image" + "image/color" + "image/draw" + "image/png" + "io" + "testing" + + "github.com/potassium5703/texture" +) + +func Render(img image.Image, rect image.Rectangle) image.Image { + newimg := image.NewRGBA(rect) + draw.Draw(newimg, rect, image.White, image.ZP, draw.Src) + draw.Draw(newimg, rect, img, image.ZP, draw.Over) + return newimg +} + +func BenchmarkScale(b *testing.B) { + for i := 0; i < b.N; i++ { + err := png.Encode(io.Discard, + Scale(Render( + texture.New(color.White, color.Black, 2), + image.Rect(0, 0, 32, 32), + ), 32), + ) + if err != nil { + panic(err) + } + } +}