Search code examples
graphicsmagick

GraphicsMagick new a image on the fly


I am using the GraphicsMagick Wand to process images. I don't know how to new a image on the fly. I don't how to do it. There isn't any demo on the Doc
Now, I just load a 1px png image to temporarily solve it. I don't want load a image each time. It seems not the best solution.
Please help.


Solution

  • I found the solution. I think it will help others. So I answer my question.
    First, You need use MagickReadImage method to read a string XC:
    MagickReadImage(intern->magick_wand, "XC:")

    Then, set image size by using MagickScaleImage method:
    MagickScaleImage(intern->magick_wand, columns, rows)

    At last, set the format:
    MagickSetImageFormat(intern->magick_wand, format)