From e1b5deae980d93a7fa058bd794060428fbf36039 Mon Sep 17 00:00:00 2001 From: Katalina / stardust Date: Sun, 6 Aug 2017 18:42:16 -0500 Subject: [PATCH] remove logging, use a more efficient/smart pad byte array --- esi.go | 9 +++------ testpattern.png | Bin 0 -> 138 bytes 2 files changed, 3 insertions(+), 6 deletions(-) create mode 100644 testpattern.png diff --git a/esi.go b/esi.go index 4e0abde..386f657 100644 --- a/esi.go +++ b/esi.go @@ -42,7 +42,6 @@ import ( "image" "image/color" "io" - "log" ) var ( @@ -66,12 +65,8 @@ func Decode(r io.Reader) (o image.Image, err error) { return o, err } - log.Println(cfg) - bounds := image.Rect(0, 0, cfg.Width, cfg.Height) - log.Println(bounds) - img := image.NewRGBA(bounds) buf.Next(8 + emptyBytes) @@ -183,7 +178,9 @@ func Encode(w io.Writer, img image.Image) error { configByte |= 32 } - _, err = w.Write([]byte{configByte, 0, 0, 0, 0, 0}) + cfgpad := make([]byte, 2+emptyBytes) // 1 byte for config, 1 empty byte, and a number of empty bytes. + cfgpad[0] = configByte + _, err = w.Write(cfgpad) if err != nil { return err } diff --git a/testpattern.png b/testpattern.png new file mode 100644 index 0000000000000000000000000000000000000000..24a331c5dd15560718cb56bb26cb4fab482fc7d3 GIT binary patch literal 138 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1SGw4HSYkaKu;IPkcv4uC*N`&G2m%VeEFe% z{R6=*|3z+|Xuq^&iF~8NA3Mec&(*J)IDAk)nR)N{g?ox86MNKdU3E@6cze;Rf_-=M mHry80>pt^mOFhuM|NmcksoAAhJ`n