コード例 #1
0
ファイル: image.go プロジェクト: zesus19/nephele
/*
Rotate() rotates an image the specified number of degrees.

degrees: degrees of the rotated image
*/
func (this *Image) Rotate(degrees float64) error {
	if this.magickWand == nil {
		return errors.New("error rotate image:magickwand is nil")
	}

	status := C.rotateImage(this.magickWand, C.double(degrees))
	if status == 0 {
		var etype int
		descr := C.MagickGetException(this.magickWand, (*C.ExceptionType)(unsafe.Pointer(&etype)))
		defer C.MagickRelinquishMemory(unsafe.Pointer(descr))
		return errors.New(fmt.Sprintf("error rotate image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
コード例 #2
0
ファイル: image.go プロジェクト: cannonhuang/nephele
/*
Rotate() rotates an image the specified number of degrees.

degrees: degrees of the rotated image
*/
func (this *Image) Rotate(degrees float64) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "Rotate")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error rotate image:magickwand is nil")
		return err
	}

	status := C.rotateImage(this.magickWand, C.double(degrees))
	if status == 0 {
		var etype int
		descr := C.MagickGetException(this.magickWand, (*C.ExceptionType)(unsafe.Pointer(&etype)))
		defer C.MagickRelinquishMemory(unsafe.Pointer(descr))
		err = errors.New(fmt.Sprintf("error rotate image: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}