mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 16:55:11 +01:00
Add test/data/checkerboard.*.png
This commit is contained in:
1 parent
b003f9fe65
commit
6ea3144379
4 files changed
+36
-13
No files matched your search
@@ -35,8 +35,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gama = flag.Float64("gama", 0, "Gamma correction value (e.g. 2.2)")
|
checkerboard = flag.Bool("checkerboard", false, "Create a checkerboard pattern instead")
|
||||||
iccp = flag.String("iccp", "", "ICC filename (e.g. foo/bar.icc)")
|
gama = flag.Float64("gama", 0, "Gamma correction value (e.g. 2.2)")
|
||||||
|
iccp = flag.String("iccp", "", "ICC filename (e.g. foo/bar.icc)")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -49,22 +50,42 @@ func main() {
|
|||||||
func main1() error {
|
func main1() error {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// Make a red-blue gradient.
|
// Make a checkerboard or red-blue gradient.
|
||||||
m := image.NewRGBA(image.Rect(0, 0, 16, 16))
|
src := image.Image(nil)
|
||||||
for y := 0; y < 16; y++ {
|
if *checkerboard {
|
||||||
for x := 0; x < 16; x++ {
|
// With -gama=1.0 (or -gama=2.2), the two halves of this image should
|
||||||
m.SetRGBA(x, y, color.RGBA{
|
// have roughly equal (or un-equal) brightness.
|
||||||
R: uint8(x * 0x11),
|
m := image.NewGray(image.Rect(0, 0, 256, 256))
|
||||||
G: 0x00,
|
for y := 0; y < 256; y++ {
|
||||||
B: uint8(y * 0x11),
|
for x := 0; x < 256; x++ {
|
||||||
A: 0xFF,
|
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))
|
||||||
|
for y := 0; y < 16; y++ {
|
||||||
|
for x := 0; x < 16; x++ {
|
||||||
|
m.SetRGBA(x, y, color.RGBA{
|
||||||
|
R: uint8(x * 0x11),
|
||||||
|
G: 0x00,
|
||||||
|
B: uint8(y * 0x11),
|
||||||
|
A: 0xFF,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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
|
||||||
|
|||||||
@@ -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 |
Reference in new issue
Block a user