c - MagickWand 库 : write to buffer instead of file

标签 c imagemagick

如何使用 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. Use MagickSetImageFormat() 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/

相关文章:

ruby-on-rails - 无法在 OS X Mountain Lion 上安装 RMagick

c - 段错误 - 将命令分割成标记

c - 在 C 中使用 msgpack 接收流

c - 为什么包含使用完整路径的 header 会导致更好的错误消息?

perl - 使用 Image::Magick 和 Perl 使背景透明

php - 如何在开罗获得更好的抗锯齿效果(所示示例)

C:有效地循环大数组

函数声明中的 const

python - 在 python/PIL 中执行与 ImageMagick 的 "-level"相同的操作?

php - 如何检测动画 GIF 的每秒滴答声?