Пример #1
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)
}
Пример #2
0
// Sets the font pointsize to use when annotating with text.
//
// pointSize: text pointsize
func (dw *DrawingWand) SetFontSize(pointSize float64) {
	C.DrawSetFontSize(dw.dw, C.double(pointSize))
}
Пример #3
0
// Sets canvas' default font size
func (self *Canvas) SetFontSize(size float64) {
	self.text.Size = size
	C.DrawSetFontSize(self.drawing, C.double(size))
}