Skip to content

小建议 #21

Description

@neil-mao

拜读了你的代码,非常不错的工作,看到你的Util,有几个小建议

  1. 没有必要进行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)
}
}

  1. util 的接口都是 文件 filename ,可以改一下,有时候是从网络上读取的字节流

  2. 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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions