Add test/data/checkerboard.*.png

This commit is contained in:
Nigel Tao committed 2021-10-20 09:58:42 +11:00
1 parent b003f9fe65
commit 6ea3144379
4 files changed
+25 -2

No files matched your search

+23 -2
View File
@@ -35,6 +35,7 @@ import (
) )
var ( var (
checkerboard = flag.Bool("checkerboard", false, "Create a checkerboard pattern instead")
gama = flag.Float64("gama", 0, "Gamma correction value (e.g. 2.2)") gama = flag.Float64("gama", 0, "Gamma correction value (e.g. 2.2)")
iccp = flag.String("iccp", "", "ICC filename (e.g. foo/bar.icc)") iccp = flag.String("iccp", "", "ICC filename (e.g. foo/bar.icc)")
) )
@@ -49,7 +50,25 @@ func main() {
func main1() error { func main1() error {
flag.Parse() flag.Parse()
// Make a red-blue gradient. // Make a checkerboard or red-blue gradient.
src := image.Image(nil)
if *checkerboard {
// With -gama=1.0 (or -gama=2.2), the two halves of this image should
// have roughly equal (or un-equal) brightness.
m := image.NewGray(image.Rect(0, 0, 256, 256))
for y := 0; y < 256; y++ {
for x := 0; x < 256; x++ {
if x < 128 {
m.SetGray(x, y, color.Gray{0x80})
} else if ((x ^ y) & 1) == 1 {
m.SetGray(x, y, color.Gray{0xFF})
} else {
m.SetGray(x, y, color.Gray{0x00})
}
}
}
src = m
} else {
m := image.NewRGBA(image.Rect(0, 0, 16, 16)) m := image.NewRGBA(image.Rect(0, 0, 16, 16))
for y := 0; y < 16; y++ { for y := 0; y < 16; y++ {
for x := 0; x < 16; x++ { for x := 0; x < 16; x++ {
@@ -61,10 +80,12 @@ func main1() error {
}) })
} }
} }
src = m
}
// Encode to PNG. // Encode to PNG.
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
png.Encode(buf, m) png.Encode(buf, src)
original := buf.Bytes() original := buf.Bytes()
// Split the encoding into a magic+IHDR prefix and an IDAT+IEND suffix. The // Split the encoding into a magic+IHDR prefix and an IDAT+IEND suffix. The
+2
View File
@@ -49,6 +49,8 @@ library.
`cbor-rfc-7049-examples.*.json` files were then generated by `cbor-rfc-7049-examples.*.json` files were then generated by
`example/cbor-to-json`. `example/cbor-to-json`.
`checkerboard.*.png` was generated by `script/make-red-blue-gradient.go`.
`crude-flag.*` is an original animation by Nigel Tao `crude-flag.*` is an original animation by Nigel Tao
<nigeltao@golang.org>. See the `lib/nie` documentation. <nigeltao@golang.org>. See the `lib/nie` documentation.
Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B