Example #1
0
File: gd.go Project: eryx/go-gd
func ImageToGifBuffer(p *Image) []byte {
	var imgSize int
	pimgSize := (*C.int)(Pointer(&imgSize))

	buf := C.gdImageGifPtr(p.img, pimgSize)
	defer C.gdFree(buf)

	return C.GoBytes(buf, *pimgSize)
}
Example #2
0
func (p *gdImage) gdImageGif() ([]byte, error) {
	if p == nil {
		panic(imageError)
	}

	var size C.int

	data := C.gdImageGifPtr(p.img, &size)
	if data == nil || int(size) == 0 {
		return []byte{}, writeError
	}

	defer C.gdFree(unsafe.Pointer(data))

	return C.GoBytes(data, size), nil
}