示例#1
0
// Puts a canvas on top of the current one.
func (cv Canvas) AppendCanvas(source Canvas, x int, y int) bool {
	status := C.MagickCompositeImage(cv.wand, source.wand, C.OverCompositeOp, C.ssize_t(x), C.ssize_t(y))
	if status == C.MagickFalse {
		return false
	}
	return true
}
示例#2
0
/*
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
}
示例#3
0
/* Composite one image onto another at the specified offset. */
func (w *MagickWand) CompositeImage(srcWand *MagickWand, compose, x, y int) error {
	if C.MagickCompositeImage(w.wand, srcWand.wand, C.CompositeOperator(compose), C.ssize_t(x), C.ssize_t(y)) == C.MagickFalse {
		eStr, eCode := w.Exception()
		return fmt.Errorf("CompositeImage() failed : [%d] %s", eStr, eCode)
	}

	return nil
}
示例#4
0
文件: canvas.go 项目: phacops/canvas
// Puts a canvas on top of the current one.
func (self *Canvas) AppendCanvas(source *Canvas, x int, y int) error {
	success := C.MagickCompositeImage(self.wand, source.wand, C.OverCompositeOp, C.ssize_t(x), C.ssize_t(y))

	if success == C.MagickFalse {
		return fmt.Errorf("Could not append image: %s", self.Error())
	}

	return nil
}
示例#5
0
文件: mage.go 项目: dqminh/mage
// Private: center the current wand on top of the new wand, after that, we only
// keep the new wand.
//
// Params:
// - newWand: new wand, probably going to be result of blankWand
// - x: x position on the current wand that is the center of the new wand
// - y: y position on the current wand that is the center of the new wand
//
// Example:
//  newWand := blankWand("jpg", width, height)
//  done := m.compositeCenter(newWand, 10, 10)
//
// Return boolean result of the composition
func (m *Mage) compositeCenter(newWand *C.MagickWand, x, y int) bool {
	success := C.MagickCompositeImage(
		newWand,
		m.wand,
		C.OverCompositeOp,
		C.ssize_t(x),
		C.ssize_t(y))
	C.DestroyMagickWand(m.wand)
	m.wand = newWand
	return mBoolean(success)
}
示例#6
0
文件: image.go 项目: zesus19/nephele
/*
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
}