Beispiel #1
0
// Creates an empty canvas of the given dimensions.
func (cv Canvas) Blank(width uint, height uint) bool {
	status := C.MagickNewImage(cv.wand, C.size_t(width), C.size_t(height), cv.bg)
	if status == C.MagickFalse {
		return false
	}
	return true
}
Beispiel #2
0
// Adds a blank image canvas of the specified size and background color to the
// wand.
func (w *MagickWand) NewImage(cols, rows uint, bg *PixelWand) error {
	if C.MagickNewImage(w.wand, C.size_t(cols), C.size_t(rows), bg.wand) == C.MagickFalse {
		eStr, eCode := w.Exception()
		return fmt.Errorf("NewImage() failed : [%d] %s", eStr, eCode)
	}

	return nil
}
Beispiel #3
0
// Creates an empty canvas of the given dimensions.
func (self *Canvas) Blank(width uint, height uint) error {
	success := C.MagickNewImage(self.wand, C.size_t(width), C.size_t(height), self.bg)

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

	return nil
}
Beispiel #4
0
// 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
}