コード例 #1
0
ファイル: resize.go プロジェクト: jbardin/go_talks
func Save(img *C.Image, path string) error {
	strCopy(&img.filename, []byte(path))

	if C.WriteImage(imageInfo, img) == 0 {
		C.CatchException(&img.exception)
		return fmt.Errorf(C.GoString(img.exception.reason))
	}
	return nil
}
コード例 #2
0
ファイル: resize.go プロジェクト: jbardin/go_talks
func Resize(img *C.Image, x, y int) (*C.Image, error) {
	newImg := C.ResizeImage(img, C.ulong(x), C.ulong(y), C.LanczosFilter, 1.0, &exceptionInfo)

	if newImg == nil {
		C.CatchException(&exceptionInfo)
		return nil, fmt.Errorf(C.GoString(exceptionInfo.reason))
	}

	C.DestroyImage(img)
	return newImg, nil
}
コード例 #3
0
ファイル: resize.go プロジェクト: jbardin/go_talks
func Read(path string) (*C.Image, error) {
	strCopy(&imageInfo.filename, []byte(path))

	img := C.ReadImage(imageInfo, &exceptionInfo)
	if img == nil {
		C.CatchException(&exceptionInfo)
		return nil, fmt.Errorf(C.GoString(exceptionInfo.reason))
	}

	return img, nil
}