Documentation ¶
Index ¶
- Variables
- func Assert(t TestingT, img image.Image, filename string)
- func Base64SplitLines(b []byte) []byte
- func CloneAsRGBA(src image.Image) *image.RGBA
- func CompareColors(cc, ic color.RGBA, tol int) bool
- func CompareUint8(cc, ic uint8, tol int) bool
- func FromBase64(fmt string, eb []byte) (image.Image, error)
- func FromBase64JPG(eb []byte) (image.Image, error)
- func FromBase64PNG(eb []byte) (image.Image, error)
- func Save(im image.Image, filename string) error
- func ToBase64JPG(img image.Image) ([]byte, string)
- func ToBase64PNG(img image.Image) ([]byte, string)
- func Write(im image.Image, w io.Writer, f Formats) error
- type Formats
- func (i Formats) Desc() string
- func (i Formats) Int64() int64
- func (i Formats) MarshalText() ([]byte, error)
- func (i *Formats) SetInt64(in int64)
- func (i *Formats) SetString(s string) error
- func (i Formats) String() string
- func (i *Formats) UnmarshalText(text []byte) error
- func (i Formats) Values() []enums.Enum
- type TestingT
Constants ¶
This section is empty.
Variables ¶
var UpdateTestImages = updateTestImages
UpdateTestImages indicates whether to update currently saved test images in [AssertImage] instead of comparing against them. It is automatically set if the build tag "update" is specified, and it should typically only be set through that. It should only be set when behavior has been updated that causes test images to change, and it should only be set once and then turned back off.
Functions ¶
func Assert ¶
Assert asserts that the given image is equivalent to the image stored at the given filename in the testdata directory, with ".png" added to the filename if there is no extension (eg: "button" becomes "testdata/button.png"). Forward slashes are automatically replaced with backslashes on Windows. If it is not, it fails the test with an error, but continues its execution. If there is no image at the given filename in the testdata directory, it creates the image.
func Base64SplitLines ¶
Base64SplitLines splits the encoded Base64 bytes into standard lines of 76 chars each. The last line also ends in a newline
func CloneAsRGBA ¶
CloneAsRGBA returns an RGBA copy of the supplied image.
func CompareColors ¶
CompareColors returns true if two colors are more different than tol
func CompareUint8 ¶
CompareUint8 returns true if two numbers are more different than tol
func FromBase64 ¶
FromBase64 returns image from Base64-encoded bytes in either PNG or JPEG format based on fmt which must end in either png, jpg, or jpeg
func FromBase64JPG ¶
FromBase64JPG returns image from Base64-encoded bytes in PNG format
func FromBase64PNG ¶
FromBase64PNG returns image from Base64-encoded bytes in PNG format
func Save ¶
Save saves the image to the given filename, with the format inferred from the filename. png, jpeg, gif, tiff, and bmp are supported.
func ToBase64JPG ¶
ToBase64JPG returns bytes image encoded as a JPG in Base64 format with "image/jpeg" mimetype returned
func ToBase64PNG ¶
ToBase64PNG returns bytes of image encoded as a PNG in Base64 format with "image/png" mimetype returned
Types ¶
type Formats ¶
type Formats int32 //enums:enum
Formats are the supported image encoding / decoding formats
const FormatsN Formats = 7
FormatsN is the highest valid value for type Formats, plus one.
func ExtToFormat ¶
ExtToFormat returns a Format based on a filename extension, which can start with a . or not
func FormatsValues ¶
func FormatsValues() []Formats
FormatsValues returns all possible values for the type Formats.
func Open ¶
Open opens an image from the given filename. The format is inferred automatically, and is returned using the Formats enum. png, jpeg, gif, tiff, bmp, and webp are supported.
func OpenFS ¶
OpenFS opens an image from the given filename using the given fs.FS filesystem (e.g., for embed files). The format is inferred automatically, and is returned using the Formats enum. png, jpeg, gif, tiff, bmp, and webp are supported.
func Read ¶
Read reads an image to the given reader, The format is inferred automatically, and is returned using the Formats enum. png, jpeg, gif, tiff, bmp, and webp are supported.
func (Formats) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Formats) SetString ¶
SetString sets the Formats value from its string representation, and returns an error if the string is invalid.
func (*Formats) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.