Image converts an image.Image to DisplayData containing PNG []byte, or to DisplayData containing error if the conversion fails
(img image.Image)
| 9 | // Image converts an image.Image to DisplayData containing PNG []byte, |
| 10 | // or to DisplayData containing error if the conversion fails |
| 11 | func Image(img image.Image) Data { |
| 12 | bytes, mimeType, err := encodePng(img) |
| 13 | if err != nil { |
| 14 | return makeDataErr(err) |
| 15 | } |
| 16 | return Data{ |
| 17 | Data: MIMEMap{ |
| 18 | mimeType: bytes, |
| 19 | }, |
| 20 | Metadata: MIMEMap{ |
| 21 | mimeType: imageMetadata(img), |
| 22 | }, |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | // encodePng converts an image.Image to PNG []byte |
| 27 | func encodePng(img image.Image) (data []byte, mimeType string, err error) { |
nothing calls this directly
no test coverage detected