diff --git a/README.md b/README.md index e28a14d..09a8d77 100644 --- a/README.md +++ b/README.md @@ -1,17 +1 @@ -# esi - -Go version of @AlexPoulsen's ESI format. - -See original repo for more info: https://github.com/AlexPoulsen/esi - -This package is compatible with the `"image"` package. See `esiconv/main.go` for a very simple example of usage. - -## esiconv - -`esiconv` is a conversion tool, and also serves as an example for this package's usage. - -Get pre-built binaries on the [Releases](https://github.com/kayteh/esi/releases/tag/0.1) page, or go-get via - -```bash -go get -u github.com/kayteh/esi/esiconv -``` +esi diff --git a/esi.go b/esi.go index 386f657..e1e6aad 100644 --- a/esi.go +++ b/esi.go @@ -42,6 +42,7 @@ import ( "image" "image/color" "io" + "log" ) var ( @@ -49,7 +50,7 @@ var ( errNotESI = errors.New("esi: not an esi") ) -var emptyBytes = 4 +var emptyBytes = 7 func init() { image.RegisterFormat("esi", "esi1", Decode, DecodeConfig) @@ -65,11 +66,15 @@ 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) + buf.Next(8 + 7) for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { @@ -178,9 +183,7 @@ func Encode(w io.Writer, img image.Image) error { configByte |= 32 } - 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) + _, err = w.Write([]byte{configByte, 0, 0, 0, 0, 0, 0, 0, 0}) if err != nil { return err } diff --git a/esiconv/main.go b/esiconv/main.go index 5280259..fe6cb42 100644 --- a/esiconv/main.go +++ b/esiconv/main.go @@ -9,7 +9,7 @@ import ( "os" "path" - "git.sapphic.engineer/noe/esi" + "github.com/kayteh/esi" ) func main() { diff --git a/go.mod b/go.mod deleted file mode 100644 index 16edcd4..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module git.sapphic.engineer/noe/esi - -go 1.23.2 diff --git a/go.sum b/go.sum deleted file mode 100644 index e69de29..0000000 diff --git a/testpattern.png b/testpattern.png deleted file mode 100644 index 24a331c..0000000 Binary files a/testpattern.png and /dev/null differ