mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Add test/data/red-blue-gradient.dcip3d65.png
This commit is contained in:
1 parent
ad1d983698
commit
e6733aec19
6 files changed
+24
-2
No files matched your search
@@ -24,6 +24,7 @@ package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/zlib"
|
||||
"flag"
|
||||
"hash/crc32"
|
||||
"image"
|
||||
@@ -34,7 +35,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
gama = flag.Float64("gama", 2.2, "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)")
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -71,7 +73,8 @@ func main1() error {
|
||||
out := []byte(nil)
|
||||
out = append(out, prefix...)
|
||||
|
||||
// Insert the optional gAMA chunk between the prefix and suffix.
|
||||
// Insert the optional chunks between the prefix and suffix.
|
||||
|
||||
if *gama > 0 {
|
||||
g := uint32(math.Round(100000 / *gama))
|
||||
out = appendPNGChunk(out, "gAMA",
|
||||
@@ -82,6 +85,20 @@ func main1() error {
|
||||
)
|
||||
}
|
||||
|
||||
if *iccp != "" {
|
||||
raw, err := os.ReadFile(*iccp)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := &bytes.Buffer{}
|
||||
data.WriteString("icc\x00") // An arbitrary NUL terminated name.
|
||||
data.WriteByte(0x00) // 0x00 means zlib compression.
|
||||
w := zlib.NewWriter(data)
|
||||
w.Write(raw)
|
||||
w.Close()
|
||||
out = appendPNGChunk(out, "iCCP", data.Bytes()...)
|
||||
}
|
||||
|
||||
// Append the suffix and write to stdout.
|
||||
out = append(out, suffix...)
|
||||
_, err := os.Stdout.Write(out)
|
||||
|
||||
Reference in new issue
Block a user