Compare commits
8 commits
Author | SHA1 | Date | |
---|---|---|---|
0ab3bc1939 | |||
e93020232f | |||
ccf9b0bf8c | |||
|
02783d6959 | ||
3146a5769a | |||
51f1eedec7 | |||
e1b5deae98 | |||
306f8d006f |
6 changed files with 26 additions and 10 deletions
18
README.md
18
README.md
|
@ -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
13
esi.go
|
@ -42,7 +42,6 @@ import (
|
|||
"image"
|
||||
"image/color"
|
||||
"io"
|
||||
"log"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -50,7 +49,7 @@ var (
|
|||
errNotESI = errors.New("esi: not an esi")
|
||||
)
|
||||
|
||||
var emptyBytes = 7
|
||||
var emptyBytes = 4
|
||||
|
||||
func init() {
|
||||
image.RegisterFormat("esi", "esi1", Decode, DecodeConfig)
|
||||
|
@ -66,15 +65,11 @@ 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 + 7)
|
||||
buf.Next(8 + emptyBytes)
|
||||
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
|
||||
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
|
||||
}
|
||||
|
||||
_, 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 {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/kayteh/esi"
|
||||
"git.sapphic.engineer/noe/esi"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
|
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module git.sapphic.engineer/noe/esi
|
||||
|
||||
go 1.23.2
|
0
go.sum
Normal file
0
go.sum
Normal file
BIN
testpattern.png
Normal file
BIN
testpattern.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 138 B |
Loading…
Add table
Reference in a new issue