示例#1
0
func (self *Canvas) DrawAnnotation(content string, width, height uint) error {
	ccontent := C.CString("caption:" + content)
	defer C.free(unsafe.Pointer(ccontent))

	C.DrawAnnotation(self.drawing, 20, 20, (*C.uchar)(unsafe.Pointer(ccontent)))

	if C.MagickDrawImage(self.wand, self.drawing) == C.MagickFalse {
		return fmt.Errorf(`Could not draw annotation: %s`, self.Error())
	}

	return nil
}
示例#2
0
func (im *Image) AnnotateImage(x, y int, text string, fontSize int, color string) {
	image_info := C.CloneImageInfo(nil)
	defer C.DestroyImageInfo(image_info)

	draw_info := C.CloneDrawInfo(image_info, nil)
	defer C.DestroyDrawInfo(draw_info)

	textBytes := []byte(text)
	bytesPointer := unsafe.Pointer(&textBytes[0])

	textArray := (*C.uchar)(bytesPointer)

	colorArray := C.CString(color)
	defer C.free(unsafe.Pointer(colorArray))

	draw_context := C.DrawAllocateContext(draw_info, im.image)
	defer C.DrawDestroyContext(draw_context)

	C.DrawSetFontSize(draw_context, C.double(fontSize))
	C.DrawSetStrokeColorString(draw_context, colorArray)
	C.DrawSetFillColorString(draw_context, colorArray)
	C.DrawAnnotation(draw_context, C.double(x), C.double(y), textArray)
	C.DrawRender(draw_context)
}
示例#3
0
文件: canvas.go 项目: phacops/canvas
func (self *Canvas) DrawAnnotation(content string, width, height uint) {
	ccontent := C.CString("caption:" + content)
	defer C.free(unsafe.Pointer(ccontent))

	C.DrawAnnotation(self.drawing, C.double(width), C.double(height), (*C.uchar)(unsafe.Pointer(ccontent)))
}
示例#4
0
// Draws text on the image.
// x: x ordinate to left of text
// y: y ordinate to text baseline
// text: text to draw
func (dw *DrawingWand) Annotation(x, y float64, text string) {
	cstext := (*C.uchar)((unsafe.Pointer)(C.CString(text)))
	defer C.free(unsafe.Pointer(cstext))
	C.DrawAnnotation(dw.dw, C.double(x), C.double(y), cstext)
}
示例#5
0
// Draws a string at the specified coordinates and using the current canvas
// Alignment.
func (self *Canvas) Annotate(text string, x, y float64) {
	c_text := C.CString(text)
	defer C.free(unsafe.Pointer(c_text))
	C.DrawAnnotation(self.drawing, C.double(x), C.double(y), (*C.uchar)(unsafe.Pointer(c_text)))
}