如何使用 MagickWand 在缓冲区(unsigned char*)中写入内容?
目前我生成一个图像并将其保存到文件中,但我需要它在内存中:
MagickNewImage( wand, 640, 480, p_wand );
MagickWriteImage( wand, "test.jpg" );
最佳答案
根据文档,有一个函数 MagickGetImageBlob
返回 unsigned char *
这似乎是您正在寻找的东西。其确切文档是
MagickGetImageBlob()
implements direct to memory image formats. It returns the image as a blob (a formatted "file" in memory) and its length, starting from the current position in the image sequence. UseMagickSetImageFormat()
to set the format to write to the blob (GIF, JPEG, PNG, etc.).
请注意,这确实需要您使用 MagickSetImageFormat
设置格式,但总的来说,这似乎是最接近您正在寻找的内容。
关于c - MagickWand 库 : write to buffer instead of file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41417927/