我想使用 GraphicsMagick C API(低级)在空白图像上写一个文本。这是我的代码。
ExceptionInfo exception;
InitializeMagick(0);
GetExceptionInfo(&exception);
ImageInfo *image_info;
Image* img;
image_info = CloneImageInfo((ImageInfo*) NULL);
strcpy(image_info->filename, "test.jpg");
img = AllocateImage(image_info);
img->columns = 200;
img->rows = 200;
img->x_resolution = 100;
img->y_resolution = 100;
DrawContext dr = DrawAllocateContext(NULL, img);
DrawAnnotation(dr, 1,1, (const unsigned char*)("hello world"));
WriteImage(image_info, img);
return "";
图像已创建,但大小为零。我不明白如何初始化所有这些结构。谢谢