newImage creates a new NRGBA image with the specified dimensions and pixel color data. If the length of pixels is 1, the entire image is filled with that color.
(w, h int, pixels ...color.Color)
| 31 | // color data. If the length of pixels is 1, the entire image is filled with |
| 32 | // that color. |
| 33 | func newImage(w, h int, pixels ...color.Color) image.Image { |
| 34 | m := image.NewNRGBA(image.Rect(0, 0, w, h)) |
| 35 | if len(pixels) == 1 { |
| 36 | draw.Draw(m, m.Bounds(), &image.Uniform{pixels[0]}, image.Point{}, draw.Src) |
| 37 | } else { |
| 38 | for i, p := range pixels { |
| 39 | m.Set(i%w, i/w, p) |
| 40 | } |
| 41 | } |
| 42 | return m |
| 43 | } |
| 44 | |
| 45 | func TestResizeParams(t *testing.T) { |
| 46 | src := image.NewNRGBA(image.Rect(0, 0, 64, 128)) |
no test coverage detected