Bpg
BPG decoder for Go (Zero Dependencies).
Install / Use
/learn @chai2010/BpgREADME
- Go语言QQ群: 102319854, 1055927514
- 凹语言(凹读音“Wa”)(The Wa Programming Language): https://github.com/wa-lang/wa
BPG for Go
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:
package main
import (
"bytes"
"fmt"
"image/png"
"io/ioutil"
"log"
"github.com/chai2010/bpg"
)
func main() {
var buf bytes.Buffer
var data []byte
var err error
data, 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 chaishushan@gmail.com.
Thanks!
Related Skills
node-connect
343.1kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
90.0kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.1kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.1kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
