找了半天找不到一个适用的切图工具,自己简单写了一个
package main
import (
"bufio"
"fmt"
"image"
"image/color"
"image/jpeg"
_ "image/png"
"os"
"strconv"
"golang.org/x/image/draw"
)
func main() {
img := readPic("static/gz.jpg")
//查看图片大小
x := img.Bounds().Dx()
y := img.Bounds().Dy()
fmt.Println("111")
fmt.Println(x, "-", y)
acimg(img, 1)
}
func acimg(img image.Image, b int) {
x := img.Bounds().Dx()
y := img.Bounds().Dy()
newx := x / b
newy := y / b
newimg := resizePic(img, newx, newy, true, 0, true)
xx := newimg.Bounds().Dx()
yy := newimg.Bounds().Dy()
fmt.Println("111")
fmt.Println(xx, "-", yy)
xn := xx / 250
yn := xx / 250
for i := 0; i < xn; i++ {
for ii := 0; ii < yn; ii++ {
sx := i * 250
sy := ii * 250
ex := (i + 1) * 250