Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chai2010/bpg
BPG decoder for Go (Zero Dependencies).
https://github.com/chai2010/bpg
Last synced: about 2 months ago
JSON representation
BPG decoder for Go (Zero Dependencies).
- Host: GitHub
- URL: https://github.com/chai2010/bpg
- Owner: chai2010
- Created: 2014-12-15T10:01:08.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2020-07-05T09:45:15.000Z (over 4 years ago)
- Last Synced: 2024-11-01T12:42:16.483Z (2 months ago)
- Language: Go
- Homepage: http://godoc.org/github.com/chai2010/bpg
- Size: 3.78 MB
- Stars: 20
- Watchers: 4
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
- *Go语言QQ群: 102319854, 1055927514*
- *凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa*----
# BPG for Go
[![Build Status](https://travis-ci.org/chai2010/bpg.svg)](https://travis-ci.org/chai2010/bpg)
[![GoDoc](https://godoc.org/github.com/chai2010/bpg?status.svg)](https://godoc.org/github.com/chai2010/bpg)BPG is defined at:
http://bellard.org/bpg/# Install
Install `GCC` or `MinGW` (http://tdm-gcc.tdragon.net/download) at first,
and then run these commands:1. Assure set the `CGO_ENABLED` environment variable to `1` to enable `CGO` (Default is enabled).
2. `go get github.com/chai2010/bpg`
3. `go run hello.go`# Examples
This is a simple example:
```Go
package mainimport (
"bytes"
"fmt"
"image/png"
"io/ioutil"
"log""github.com/chai2010/bpg"
)func main() {
var buf bytes.Buffer
var data []byte
var err errordata, err = ioutil.ReadFile("./testdata/lena512color.bpg")
if err != nil {
log.Println(err)
}
info, err := bpg.DecodeInfo(data)
if err != nil {
log.Println(err)
}
fmt.Printf("info: %v\n", info)// Decode bpg
m, err := bpg.Decode(bytes.NewReader(data))
if err != nil {
log.Println(err)
}// save as png
if err = png.Encode(&buf, m); err != nil {
log.Println(err)
}
if err = ioutil.WriteFile("output.png", buf.Bytes(), 0666); err != nil {
log.Println(err)
}fmt.Println("Save as output.png")
}
```# BUGS
Report bugs to .
Thanks!