Beispiel #1
0
// Sets canvas's foreground color.
func (self *Canvas) SetColor(color string) bool {
	status := C.PixelSetColor(self.fg, C.CString(color))
	if status == C.MagickFalse {
		return false
	}
	return true
}
Beispiel #2
0
// Sets canvas' background color.
func (cv Canvas) SetBackgroundColor(color string) bool {
	C.PixelSetColor(cv.bg, C.CString(color))
	status := C.MagickSetImageBackgroundColor(cv.wand, cv.bg)
	if status == C.MagickFalse {
		return false
	}
	return true
}
Beispiel #3
0
// Sets the color of the pixel wand with a string (e.g. "blue", "#0000ff",
// "rgb(0,0,255)", "cmyk(100,100,100,10)", etc.).
func (p *PixelWand) SetColor(color string) error {
	if C.PixelSetColor(p.wand, C.CString(color)) == C.MagickFalse {
		eStr, eCode := p.Exception()
		return fmt.Errorf("SetColor() failed : [%d] %s", eStr, eCode)
	}

	return nil
}
Beispiel #4
0
func (self *Pixel) SetColor(color string) error {
	ccolor := C.CString(color)
	defer C.free(unsafe.Pointer(ccolor))

	if C.PixelSetColor(self.wand, ccolor) == C.MagickFalse {
		return fmt.Errorf("Could not set color")
	}

	return nil
}
Beispiel #5
0
// Sets canvas' background color.
func (self Canvas) SetBackgroundColor(color string) error {
	C.PixelSetColor(self.bg, C.CString(color))
	success := C.MagickSetImageBackgroundColor(self.wand, self.bg)

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

	return nil
}
Beispiel #6
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
}
Beispiel #7
0
// Sets canvas' background color.
func (self *Canvas) SetBackgroundColor(color string) error {
	var status C.MagickBooleanType

	ccolor := C.CString(color)
	status = C.PixelSetColor(self.bg, ccolor)
	C.free(unsafe.Pointer(ccolor))

	if status == C.MagickFalse {
		return fmt.Errorf("Could not set pixel color: %s", self.Error())
	}

	status = C.MagickSetImageBackgroundColor(self.wand, self.bg)

	if status == C.MagickFalse {
		return fmt.Errorf("Could not set background color: %s", self.Error())
	}

	return nil
}
Beispiel #8
0
// Sets the color of the pixel wand with a string (e.g. "blue", "#0000ff", "rgb(0,0,255)", "cmyk(100,100,100,10)", etc.)
func (pw *PixelWand) SetColor(color string) bool {
	cscolor := C.CString(color)
	defer C.free(unsafe.Pointer(cscolor))
	return 1 == int(C.PixelSetColor(pw.pw, cscolor))
}
Beispiel #9
0
// Sets the stroke color on the current drawing surface.
func (cv Canvas) SetStrokeColor(color string) {
	C.PixelSetColor(cv.stroke, C.CString(color))
	C.DrawSetStrokeColor(cv.drawing, cv.stroke)
}
Beispiel #10
0
// Sets the fill color for enclosed areas on the current drawing surface.
func (cv Canvas) SetFillColor(color string) {
	C.PixelSetColor(cv.fill, C.CString(color))
	C.DrawSetFillColor(cv.drawing, cv.fill)
}
Beispiel #11
0
// Sets the stroke color on the current drawing surface.
func (self *Canvas) SetStrokeColor(color string) {
	ccolor := C.CString(color)
	C.PixelSetColor(self.stroke, ccolor)
	C.free(unsafe.Pointer(ccolor))
	C.DrawSetStrokeColor(self.drawing, self.stroke)
}
Beispiel #12
0
// Sets the fill color for enclosed areas on the current drawing surface.
func (self *Canvas) SetFillColor(color string) {
	ccolor := C.CString(color)
	C.PixelSetColor(self.fill, ccolor)
	C.free(unsafe.Pointer(ccolor))
	C.DrawSetFillColor(self.drawing, self.fill)
}
Beispiel #13
0
// Sets the stroke color on the current drawing surface.
func (self Canvas) SetStrokeColor(color string) {
	C.PixelSetColor(self.stroke, C.CString(color))
	C.DrawSetStrokeColor(self.drawing, self.stroke)
}
Beispiel #14
0
// Sets the fill color for enclosed areas on the current drawing surface.
func (self Canvas) SetFillColor(color string) {
	C.PixelSetColor(self.fill, C.CString(color))
	C.DrawSetFillColor(self.drawing, self.fill)
}