(w, h int, alpha bool)
| 37 | } |
| 38 | |
| 39 | func encodePNGBytes(w, h int, alpha bool) []byte { |
| 40 | if alpha { |
| 41 | img := image.NewNRGBA(image.Rect(0, 0, w, h)) |
| 42 | for y := range h { |
| 43 | for x := range w { |
| 44 | img.Set(x, y, color.NRGBA{R: 0, G: 128, B: 255, A: 128}) |
| 45 | } |
| 46 | } |
| 47 | var buf bytes.Buffer |
| 48 | if err := png.Encode(&buf, img); err != nil { |
| 49 | panic(err) |
| 50 | } |
| 51 | return buf.Bytes() |
| 52 | } |
| 53 | img := image.NewRGBA(image.Rect(0, 0, w, h)) |
| 54 | for y := range h { |
| 55 | for x := range w { |
| 56 | img.Set(x, y, color.RGBA{R: 0, G: 128, B: 255, A: 255}) |
| 57 | } |
| 58 | } |
| 59 | var buf bytes.Buffer |
| 60 | if err := png.Encode(&buf, img); err != nil { |
| 61 | panic(err) |
| 62 | } |
| 63 | return buf.Bytes() |
| 64 | } |
| 65 | |
| 66 | func writeTempFile(t *testing.T, ext string, data []byte) string { |
| 67 | t.Helper() |
no test coverage detected