tests
This commit is contained in:
parent
04c781c03a
commit
d4aec6bcaf
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
child_porn
|
||||
imageutils.test
|
||||
cpu.out
|
4
go.mod
4
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
|
||||
|
2
go.sum
Normal file
2
go.sum
Normal file
@ -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=
|
33
scale_test.go
Normal file
33
scale_test.go
Normal file
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user