MCPcopy
hub / github.com/willnorris/imageproxy / newImage

Function newImage

transform_test.go:33–43  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

31// color data. If the length of pixels is 1, the entire image is filled with
32// that color.
33func 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
45func TestResizeParams(t *testing.T) {
46 src := image.NewNRGBA(image.Rect(0, 0, 64, 128))

Callers 6

TestTransformFunction · 0.85
TestTransform_EXIFFunction · 0.85
TestTransformImageFunction · 0.85
TestTrimEdgesFunction · 0.85

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected