PoC CGO wrapper and sample command-line utility

This commit is contained in:
mappu 2016-11-20 13:51:48 +13:00
parent 65eccee074
commit e4c1fbf490
3 changed files with 37 additions and 0 deletions

3
.hgignore Normal file
View File

@ -0,0 +1,3 @@
mode:regex
\.exe$

20
cmd/gopngquant/main.go Normal file
View File

@ -0,0 +1,20 @@
package main
import (
"flag"
"fmt"
"os"
"code.ivysaur.me/imagequant"
)
func main() {
ShouldDisplayVersion := flag.Bool("Version", false, "")
flag.Parse()
if *ShouldDisplayVersion {
fmt.Printf("libimagequant %d\n", imagequant.GetLibraryVersion())
os.Exit(1)
}
}

14
imagequant.go Normal file
View File

@ -0,0 +1,14 @@
package imagequant
/*
#cgo CFLAGS: -O3 -fno-math-errno -fopenmp -funroll-loops -fomit-frame-pointer -Wall -Wno-attributes -std=c99 -DNDEBUG -DUSE_SSE=1 -msse -fexcess-precision=fast
#cgo LDFLAGS: -fopenmp -static
#include "libimagequant.h"
*/
import (
"C"
)
func GetLibraryVersion() int {
return int(C.liq_version())
}