Files
mostlymatter/vendor/github.com/oov/psd/compress_js.go
Jesús Espino ce82ff7e2b Add psd preview support (#15078)
* Add psd preview support

* Adding required vendor files

* Adding oov/psd license to NOTICE.txt file

* Adding the license notice for gopherjs to the NOTICE.txt

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2020-07-31 14:46:22 +02:00

41 строка
889 B
Go

// +build !wasm
// +build js
package psd
import (
"errors"
"io"
"github.com/gopherjs/gopherjs/js"
)
func decodePackBits(dest []byte, r io.Reader, width int, lines int, large bool) (read int, err error) {
intSize := get4or8(large) >> 1
b := make([]byte, lines*intSize)
var l int
if l, err = io.ReadFull(r, b); err != nil {
return
}
read += l
lens := js.Global.Get("$github.com/oov/psd$").Call("decodePackBitsLines", b, lines, large).Interface().([]uint)
if lens == nil {
return read, errors.New("psd: error occurred in decodePackBitsLines")
}
total := uint(0)
for _, ln := range lens {
total += ln
}
b = make([]byte, total)
if l, err = io.ReadFull(r, b); err != nil {
return
}
read += l
if !js.Global.Get("$github.com/oov/psd$").Call("decodePackBits", dest, b, lens).Bool() {
return read, errors.New("psd: error occurred in decodePackBits")
}
return
}