Compare commits

...

8 commits
0.1 ... master

Author SHA1 Message Date
noe
0ab3bc1939 fix esiconv import 2024-11-03 20:18:03 -08:00
noe
e93020232f add go.mod 2024-11-03 20:17:38 -08:00
ccf9b0bf8c Merge pull request #1 from AlexPoulsen/patch-1
I corrected the spelling of my last name
2017-08-12 22:56:41 -05:00
Alex Poulsen
02783d6959 I corrected the spelling of my last name 2017-08-11 19:56:32 -04:00
3146a5769a Update README.md 2017-08-10 19:18:07 -05:00
51f1eedec7 Update README.md 2017-08-10 19:16:34 -05:00
e1b5deae98 remove logging, use a more efficient/smart pad byte array 2017-08-06 18:42:16 -05:00
306f8d006f overshot offsets, dialed it back. 2017-08-06 17:37:48 -05:00
6 changed files with 26 additions and 10 deletions

View file

@ -1 +1,17 @@
esi # 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
```

13
esi.go
View file

@ -42,7 +42,6 @@ import (
"image" "image"
"image/color" "image/color"
"io" "io"
"log"
) )
var ( var (
@ -50,7 +49,7 @@ var (
errNotESI = errors.New("esi: not an esi") errNotESI = errors.New("esi: not an esi")
) )
var emptyBytes = 7 var emptyBytes = 4
func init() { func init() {
image.RegisterFormat("esi", "esi1", Decode, DecodeConfig) image.RegisterFormat("esi", "esi1", Decode, DecodeConfig)
@ -66,15 +65,11 @@ func Decode(r io.Reader) (o image.Image, err error) {
return o, err return o, err
} }
log.Println(cfg)
bounds := image.Rect(0, 0, cfg.Width, cfg.Height) bounds := image.Rect(0, 0, cfg.Width, cfg.Height)
log.Println(bounds)
img := image.NewRGBA(bounds) img := image.NewRGBA(bounds)
buf.Next(8 + 7) buf.Next(8 + emptyBytes)
for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
for x := bounds.Min.X; x < bounds.Max.X; x++ { for x := bounds.Min.X; x < bounds.Max.X; x++ {
@ -183,7 +178,9 @@ func Encode(w io.Writer, img image.Image) error {
configByte |= 32 configByte |= 32
} }
_, err = w.Write([]byte{configByte, 0, 0, 0, 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 { if err != nil {
return err return err
} }

View file

@ -9,7 +9,7 @@ import (
"os" "os"
"path" "path"
"github.com/kayteh/esi" "git.sapphic.engineer/noe/esi"
) )
func main() { func main() {

3
go.mod Normal file
View file

@ -0,0 +1,3 @@
module git.sapphic.engineer/noe/esi
go 1.23.2

0
go.sum Normal file
View file

BIN
testpattern.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B