예제 #1
0
파일: canvas.go 프로젝트: Terry-Mao/canvas
// Destroys canvas.
func (self Canvas) Destroy() error {

	if self.wand != nil {
		C.DestroyMagickWand(self.wand)
		self.wand = nil
	}

	if self.bg != nil {
		C.DestroyPixelWand(self.bg)
		self.bg = nil
	}

	if self.fg != nil {
		C.DestroyPixelWand(self.fg)
		self.fg = nil
	}

	if self.stroke != nil {
		C.DestroyPixelWand(self.stroke)
		self.stroke = nil
	}

	if self.fill != nil {
		C.DestroyPixelWand(self.fill)
		self.fill = nil
	}

	if self.drawing != nil {
		C.DestroyDrawingWand(self.drawing)
		self.drawing = nil
	}

	return fmt.Errorf("Nothing to destroy")
}
예제 #2
0
// Deallocates resources associated with a pixel wand
func (pw *PixelWand) Destroy() {
	if pw.pw == nil {
		return
	}
	pw.pw = C.DestroyPixelWand(pw.pw)
	C.free(unsafe.Pointer(pw.pw))
	pw.pw = nil
}
예제 #3
0
// Deallocates resources associated with a pixel wand
func (pw *PixelWand) Destroy() {
	if pw.pw == nil {
		return
	}
	pw.pw = C.DestroyPixelWand(pw.pw)
	relinquishMemory(unsafe.Pointer(pw.pw))
	pw.pw = nil
}
예제 #4
0
// Destroys canvas.
func (self *Canvas) Destroy() error {

	if self.bg != nil {
		C.DestroyPixelWand(self.bg)
		self.bg = nil
	}

	if self.fg != nil {
		C.DestroyPixelWand(self.fg)
		self.fg = nil
	}

	if self.stroke != nil {
		C.DestroyPixelWand(self.stroke)
		self.stroke = nil
	}

	if self.fill != nil {
		C.DestroyPixelWand(self.fill)
		self.fill = nil
	}

	if self.drawing != nil {
		C.DestroyDrawingWand(self.drawing)
		self.drawing = nil
	}

	if self.wand == nil {
		return errors.New("Nothing to destroy")
	} else {
		C.DestroyMagickWand(self.wand)
		self.wand = nil
	}

	if self.text != nil && self.text.UnderColor != nil {
		C.DestroyPixelWand(self.text.UnderColor)
		self.text.UnderColor = nil
	}

	return nil
}
예제 #5
0
파일: mage.go 프로젝트: dqminh/mage
// Private: Create a blank magick wand with size width and height
//
// Params:
// - format: format of the new image
// - width: width of the new image
// - height: height of the new image
//
// Examples
//  blankWand("jpg", 100, 100)
//
// Return *C.MagickWand
func blankWand(format string, width, height int) *C.MagickWand {
	wand := C.NewMagickWand()
	cformat := C.CString(format)
	noneBackground := C.CString("none")
	defer C.free(unsafe.Pointer(cformat))
	defer C.free(unsafe.Pointer(noneBackground))

	C.MagickSetFormat(wand, C.CString(format))
	pixel := C.NewPixelWand()
	defer C.DestroyPixelWand(pixel)

	C.PixelSetColor(pixel, noneBackground)
	C.MagickSetSize(wand, C.size_t(width), C.size_t(height))
	C.MagickNewImage(wand, C.size_t(width), C.size_t(height), pixel)
	return wand
}
예제 #6
0
func (self *Pixel) Destroy() {
	C.DestroyPixelWand(self.wand)
}
예제 #7
0
// Deallocates resources associated with a PixelWand.
func (p *PixelWand) Destroy() {
	C.DestroyPixelWand(p.wand)
}