当前位置: 首页>>代码示例>>Golang>>正文


Golang C.MagickGetException函数代码示例

本文整理汇总了Golang中C.MagickGetException函数的典型用法代码示例。如果您正苦于以下问题:Golang MagickGetException函数的具体用法?Golang MagickGetException怎么用?Golang MagickGetException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MagickGetException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Resize

func Resize(fpath, tpath string, typ, cols, rows int) error {
	var mw *C.MagickWand = C.NewMagickWand()
	var cfpath = C.CString(fpath)
	var ctpath = C.CString(tpath)
	var etype C.ExceptionType
	defer func() {
		C.free(unsafe.Pointer(cfpath))
		C.free(unsafe.Pointer(ctpath))
	}()
	defer func() {
		C.ClearMagickWand(mw)
		C.DestroyMagickWand(mw)
	}()
	if C.MagickReadImage(mw, cfpath) == C.MagickFalse {
		goto ERR
	}

	if C.scale(mw, C.int(typ), C.int(cols), C.int(rows)) == C.MagickFalse {
		goto ERR
	}
	if C.MagickWriteImages(mw, ctpath, C.MagickTrue) == C.MagickFalse {
		goto ERR
	}
	return nil
ERR:
	etype = C.MagickGetExceptionType(mw)
	return errors.New(C.GoString(C.MagickGetException(mw, &etype)))
}
开发者ID:Joinhack,项目名称:avconv,代码行数:28,代码来源:conv.go

示例2: WriteImageBlob

/*
WriteImageBlob() writes this image wand to Blob
*/
func (this *Image) WriteImageBlob() error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "WriteImageBlob")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error write image to blob:magickwand is nil")
		return err
	}
	var sizep int = 0

	blob := C.MagickWriteImageBlob(this.magickWand, (*C.size_t)(unsafe.Pointer(&sizep)))
	if blob != nil {
		defer C.free(unsafe.Pointer(blob))
	} else {
		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 write image to blob: %s (ExceptionType=%d)", C.GoString(descr), etype))
		return err
	}

	this.Blob = C.GoBytes(unsafe.Pointer(blob), C.int(sizep))

	return nil
}
开发者ID:cannonhuang,项目名称:nephele,代码行数:31,代码来源:image.go

示例3: SetFormat

/*
Sets the file or blob format (e.g. "BMP") to be used when a file or blob is read. Usually this is
not necessary because GraphicsMagick is able to auto-detect the format based on the file header
(or the file extension), but some formats do not use a unique header or the selection may be ambigious.
 Use MagickSetImageFormat() to set the format to be used when a file or blob is to be written.

format: The file or blob format
*/
func (this *Image) SetFormat(format string) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "SetFormat")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error set image format:magickwand is nil")
		return err
	}

	var cs *C.char = C.CString(format)
	defer C.free(unsafe.Pointer(cs))
	status := C.MagickSetImageFormat(this.magickWand, cs)
	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 set image format: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}
开发者ID:cannonhuang,项目名称:nephele,代码行数:33,代码来源:image.go

示例4: Composite

/*
Composite() composite one image onto another at the specified offset.

compositeImg: The composite image
x: The column offset of the composited image.
y: The row offset of the composited image.
*/
func (this *Image) Composite(compositeImg *Image, x int64, y int64) error {
	var err error = nil
	tran := this.Cat.NewTransaction("GraphicsMagickCmd", "Composite")
	defer func() {
		tran.SetStatus(err)
		tran.Complete()
	}()
	if this.magickWand == nil {
		err = errors.New("error composite image:magickwand is nil")
		return err
	}

	if compositeImg.magickWand == nil {
		err = errors.New("error composite image:composite image wand is nil")
		return err
	}
	status := C.MagickCompositeImage(this.magickWand, compositeImg.magickWand, C.OverCompositeOp, C.long(x), C.long(y))
	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 composite image: %s (ExceptionType = %d)", C.GoString(descr), etype))
		return err
	}

	return nil
}
开发者ID:cannonhuang,项目名称:nephele,代码行数:34,代码来源:image.go

示例5: Exception

/* Returns the severity, reason, and description of any error that occurs when
   using other methods in this API.
*/
func (w *MagickWand) Exception() (string, int) {
	var severity C.ExceptionType
	errPtr := C.MagickGetException(w.wand, &severity)
	C.MagickClearException(w.wand)
	err := C.GoString(errPtr)
	C.MagickRelinquishMemory(unsafe.Pointer(errPtr))
	return err, int(severity)
}
开发者ID:rli-diraryi,项目名称:paint,代码行数:11,代码来源:magick_wand.go

示例6: Error

// Returns the latest error reported by the MagickWand API.
func (self *Canvas) Error() error {
	var t C.ExceptionType
	ptr := C.MagickGetException(self.wand, &t)
	message := C.GoString(ptr)
	C.MagickClearException(self.wand)
	C.MagickRelinquishMemory(unsafe.Pointer(ptr))
	return errors.New(message)
}
开发者ID:phacops,项目名称:canvas,代码行数:9,代码来源:canvas.go

示例7: GetLastError

// Returns the kind, reason and description of any error that occurs when using other methods in this API
func (mw *MagickWand) GetLastError() error {
	var et C.ExceptionType
	csdescription := C.MagickGetException(mw.mw, &et)
	defer mw.relinquishMemory(unsafe.Pointer(csdescription))
	if ExceptionType(et) != EXCEPTION_UNDEFINED {
		mw.clearException()
		return &MagickWandException{ExceptionType(C.int(et)), C.GoString(csdescription)}
	}
	return nil
}
开发者ID:qwo,项目名称:abelana-gcp,代码行数:11,代码来源:magick_wand_exception.go

示例8: Error

func (self *PixelIterator) Error() error {
	var exception C.ExceptionType

	ptr := C.MagickGetException(self.iterator, &exception)
	message := C.GoString(ptr)

	C.MagickClearException(self.iterator)
	C.MagickRelinquishMemory(unsafe.Pointer(ptr))

	return errors.New(message)
}
开发者ID:phacops,项目名称:canvas,代码行数:11,代码来源:pixel_iterator.go

示例9: Strip

/*
Strip() removes all profiles and text attributes from this image.
*/
func (this *Image) Strip() error {
	if this.magickWand == nil {
		return errors.New("error strip image:magickwand is nil")
	}

	status := C.MagickStripImage(this.magickWand)
	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 strip image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:18,代码来源:image.go

示例10: Resize

func (this *Image) Resize(width int64, height int64) error {
	if this.magickWand == nil {
		return errors.New("error resizing image:magickwand is nil")
	}

	status := C.MagickResizeImage(this.magickWand, C.ulong(width), C.ulong(height), C.CubicFilter, 0.5)
	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 resizing image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:15,代码来源:image.go

示例11: SetCompressionQuality

/*
Sets the image quality factor, which determines compression options when saving the file

quality: The image quality
*/
func (this *Image) SetCompressionQuality(quality int) error {
	if this.magickWand == nil {
		return errors.New("error set image compression quality:magickwand is nil")
	}

	status := C.MagickSetCompressionQuality(this.magickWand, C.ulong(quality))
	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 set image compression quality: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:20,代码来源:image.go

示例12: Scale

/*
Scale() scales the size of this image to the given dimensions.

columns: The number of columns in the scaled image.
rows: The number of rows in the scaled image
*/
func (this *Image) Scale(columns int64, rows int64) error {
	if this.magickWand == nil {
		return errors.New("error scale image:magickwand is nil")
	}

	status := C.MagickScaleImage(this.magickWand, C.ulong(columns), C.ulong(rows))
	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 scale image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:21,代码来源:image.go

示例13: CreateWand

/*
CreateWand() creates a new wand for this Image by using Blob data
*/
func (this *Image) CreateWand() error {
	if this.magickWand != nil {
		this.DestoryWand()
	}
	status := C.createWand(&this.magickWand, (*C.uchar)(unsafe.Pointer(&this.Blob[0])), C.size_t(len(this.Blob)))
	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 create magick wand: %s (ExceptionType = %d)", C.GoString(descr), etype))
		this.DestoryWand()
		return err
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:19,代码来源:image.go

示例14: SetFormat

/*
Sets the file or blob format (e.g. "BMP") to be used when a file or blob is read. Usually this is
not necessary because GraphicsMagick is able to auto-detect the format based on the file header
(or the file extension), but some formats do not use a unique header or the selection may be ambigious.
 Use MagickSetImageFormat() to set the format to be used when a file or blob is to be written.

format: The file or blob format
*/
func (this *Image) SetFormat(format string) error {
	if this.magickWand == nil {
		return errors.New("error set image format:magickwand is nil")
	}

	var cs *C.char = C.CString(format)
	defer C.free(unsafe.Pointer(cs))
	status := C.MagickSetFormat(this.magickWand, cs)
	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 set image format: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:25,代码来源:image.go

示例15: Composite

/*
Composite() composite one image onto another at the specified offset.

compositeImg: The composite image
x: The column offset of the composited image.
y: The row offset of the composited image.
*/
func (this *Image) Composite(compositeImg *Image, x int64, y int64) error {
	if this.magickWand == nil {
		return errors.New("error composite image:magickwand is nil")
	}

	if compositeImg.magickWand == nil {
		return errors.New("error composite image:composite image wand is nil")
	}

	compositeImg.Dissolve(100)

	status := C.MagickCompositeImage(this.magickWand, compositeImg.magickWand, C.OverCompositeOp, C.long(x), C.long(y))
	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 composite image: %s (ExceptionType = %d)", C.GoString(descr), etype))
	}

	return nil
}
开发者ID:zesus19,项目名称:nephele,代码行数:28,代码来源:image.go


注:本文中的C.MagickGetException函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。