拜读了你的代码,非常不错的工作,看到你的Util,有几个小建议
- 没有必要进行resize,因为虹软的要求是 4 的倍数的宽度,读取 rgba 数组的时候,可以直接取整
for starty := 0; starty < height; starty++ {
for startx := 0; startx < newWidth; startx++ { <---- 这里直接读到4 的倍数即可
R := imgMatrix[starty][startx][0]
G := imgMatrix[starty][startx][1]
B := imgMatrix[starty][startx][2]
bgrData = append(bgrData, B, G, R)
}
}
-
util 的接口都是 文件 filename ,可以改一下,有时候是从网络上读取的字节流
-
image 转换 nrgba 可以直接 用
"golang.org/x/image/draw"
b := src.Bounds()
m := image.NewNRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(m, m.Bounds(), src, b.Min, draw.Src)
拜读了你的代码,非常不错的工作,看到你的Util,有几个小建议
for starty := 0; starty < height; starty++ {
for startx := 0; startx < newWidth; startx++ { <---- 这里直接读到4 的倍数即可
R := imgMatrix[starty][startx][0]
G := imgMatrix[starty][startx][1]
B := imgMatrix[starty][startx][2]
bgrData = append(bgrData, B, G, R)
}
}
util 的接口都是 文件 filename ,可以改一下,有时候是从网络上读取的字节流
image 转换 nrgba 可以直接 用
"golang.org/x/image/draw"
b := src.Bounds()
m := image.NewNRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(m, m.Bounds(), src, b.Min, draw.Src)