8 Star 40 Fork 10

Gitee 极速下载 / Caire

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/esimov/caire
克隆/下载
process_test.go 2.48 KB
一键复制 编辑 原始数据 按行查看 历史
esimov 提交于 2022-12-10 07:39 . test: using testify package for test cases
package caire
import (
"image"
"testing"
"github.com/stretchr/testify/assert"
)
func TestResize_ShrinkImageWidth(t *testing.T) {
assert := assert.New(t)
img := image.NewNRGBA(image.Rect(0, 0, imgWidth, imgHeight))
var c = NewCarver(img.Bounds().Dx(), img.Bounds().Dy())
newWidth := imgWidth / 2
p.NewWidth = newWidth
p.NewHeight = imgHeight
for x := 0; x < newWidth; x++ {
width, height := img.Bounds().Max.X, img.Bounds().Max.Y
c = NewCarver(width, height)
c.ComputeSeams(p, img)
seams := c.FindLowestEnergySeams(p)
img = c.RemoveSeam(img, seams, p.Debug)
}
imgWidth := img.Bounds().Max.X
assert.Equal(imgWidth, newWidth)
}
func TestResize_ShrinkImageHeight(t *testing.T) {
assert := assert.New(t)
img := image.NewNRGBA(image.Rect(0, 0, imgWidth, imgHeight))
var c = NewCarver(img.Bounds().Dx(), img.Bounds().Dy())
newHeight := imgHeight / 2
p.NewWidth = imgWidth
p.NewHeight = newHeight
img = c.RotateImage90(img)
for x := 0; x < newHeight; x++ {
width, height := img.Bounds().Max.X, img.Bounds().Max.Y
c = NewCarver(width, height)
c.ComputeSeams(p, img)
seams := c.FindLowestEnergySeams(p)
img = c.RemoveSeam(img, seams, p.Debug)
}
img = c.RotateImage270(img)
imgHeight := img.Bounds().Max.Y
assert.Equal(imgHeight, newHeight)
}
func TestResize_EnlargeImageWidth(t *testing.T) {
assert := assert.New(t)
img := image.NewNRGBA(image.Rect(0, 0, imgWidth, imgHeight))
var c = NewCarver(img.Bounds().Dx(), img.Bounds().Dy())
newWidth := imgWidth * 2
p.NewWidth = newWidth
p.NewHeight = imgHeight
for x := 0; x < newWidth; x++ {
width, height := img.Bounds().Max.X, img.Bounds().Max.Y
c = NewCarver(width, height)
c.ComputeSeams(p, img)
seams := c.FindLowestEnergySeams(p)
img = c.AddSeam(img, seams, p.Debug)
}
imgWidth := img.Bounds().Max.X - img.Bounds().Dx()
assert.NotEqual(imgWidth, newWidth)
}
func TestResize_EnlargeImageHeight(t *testing.T) {
assert := assert.New(t)
img := image.NewNRGBA(image.Rect(0, 0, imgWidth, imgHeight))
var c = NewCarver(img.Bounds().Dx(), img.Bounds().Dy())
newHeight := imgHeight * 2
p.NewWidth = imgWidth
p.NewHeight = newHeight
img = c.RotateImage90(img)
for x := 0; x < newHeight; x++ {
width, height := img.Bounds().Max.X, img.Bounds().Max.Y
c = NewCarver(width, height)
c.ComputeSeams(p, img)
seams := c.FindLowestEnergySeams(p)
img = c.AddSeam(img, seams, p.Debug)
}
img = c.RotateImage270(img)
imgHeight := img.Bounds().Max.Y - img.Bounds().Dy()
assert.NotEqual(imgHeight, newHeight)
}
Go
1
https://gitee.com/mirrors/Caire.git
git@gitee.com:mirrors/Caire.git
mirrors
Caire
Caire
master

搜索帮助