MCPcopy Create free account
hub / github.com/docker/docker-agent / encodeJPEGBytes

Function encodeJPEGBytes

pkg/chat/attach_test.go:25–37  ·  view source on GitHub ↗

────────────────────────────────────────────────────────────────────────────── Helpers ──────────────────────────────────────────────────────────────────────────────

(w, h int)

Source from the content-addressed store, hash-verified

23// ──────────────────────────────────────────────────────────────────────────────
24
25func 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
39func encodePNGBytes(w, h int, alpha bool) []byte {
40 if alpha {

Calls 2

BytesMethod · 0.95
SetMethod · 0.45

Tested by

no test coverage detected