────────────────────────────────────────────────────────────────────────────── Helpers ──────────────────────────────────────────────────────────────────────────────
(w, h int)
| 23 | // ────────────────────────────────────────────────────────────────────────────── |
| 24 | |
| 25 | func encodeJPEGBytes(w, h int) []byte { |
| 26 | img := image.NewRGBA(image.Rect(0, 0, w, h)) |
| 27 | for y := range h { |
| 28 | for x := range w { |
| 29 | img.Set(x, y, color.RGBA{R: 200, G: 100, B: 50, A: 255}) |
| 30 | } |
| 31 | } |
| 32 | var buf bytes.Buffer |
| 33 | if err := jpeg.Encode(&buf, img, &jpeg.Options{Quality: 80}); err != nil { |
| 34 | panic(err) |
| 35 | } |
| 36 | return buf.Bytes() |
| 37 | } |
| 38 | |
| 39 | func encodePNGBytes(w, h int, alpha bool) []byte { |
| 40 | if alpha { |
no test coverage detected