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 }
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) }
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))) }
// 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) }
// 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))) }