Compare commits
No commits in common. "master" and "0.1" have entirely different histories.
6 changed files with 10 additions and 26 deletions
18
README.md
18
README.md
|
@ -1,17 +1 @@
|
||||||
# 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,6 +42,7 @@ import (
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -49,7 +50,7 @@ var (
|
||||||
errNotESI = errors.New("esi: not an esi")
|
errNotESI = errors.New("esi: not an esi")
|
||||||
)
|
)
|
||||||
|
|
||||||
var emptyBytes = 4
|
var emptyBytes = 7
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
image.RegisterFormat("esi", "esi1", Decode, DecodeConfig)
|
image.RegisterFormat("esi", "esi1", Decode, DecodeConfig)
|
||||||
|
@ -65,11 +66,15 @@ 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 + emptyBytes)
|
buf.Next(8 + 7)
|
||||||
|
|
||||||
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++ {
|
||||||
|
@ -178,9 +183,7 @@ func Encode(w io.Writer, img image.Image) error {
|
||||||
configByte |= 32
|
configByte |= 32
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgpad := make([]byte, 2+emptyBytes) // 1 byte for config, 1 empty byte, and a number of empty bytes.
|
_, err = w.Write([]byte{configByte, 0, 0, 0, 0, 0, 0, 0, 0})
|
||||||
cfgpad[0] = configByte
|
|
||||||
_, err = w.Write(cfgpad)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"git.sapphic.engineer/noe/esi"
|
"github.com/kayteh/esi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
3
go.mod
3
go.mod
|
@ -1,3 +0,0 @@
|
||||||
module git.sapphic.engineer/noe/esi
|
|
||||||
|
|
||||||
go 1.23.2
|
|
0
go.sum
0
go.sum
BIN
testpattern.png
BIN
testpattern.png
Binary file not shown.
Before Width: | Height: | Size: 138 B |
Loading…
Add table
Reference in a new issue