I have been using ImageMagick's C API called MagickWand. In MagickDistortImage, I don't know how to pass second argument. Below is my code.
lib.lua
ffi.cdef([[ typedef void MagickWand;
MagickBooleanType MagickDistortImage(MagickWand *wand, const DistortMethod method, const size_t, const double *args, const MagickBooleanType bestfit);
]])
image.lua
local arg = ffi.new("const double[?]",{115.23})
local tt = handle_result(self, lib.MagickDistortImage(self.wand, Plane2CylinderDistortion, 1, arg, 1))
In my above code I don't know how to pass second argument.
I found the solution. const DistortMethod method
, it accepts enums so I just need to defined it as integer and pass the integer value. So I modified my code to.
lib.lua
ffi.cdef([[
typedef void MagickWand;
typedef const int DistortMethod;
MagickBooleanType MagickDistortImage(MagickWand *wand, DistortMethod method, const size_t, const double *args, const MagickBooleanType bestfit);
]])
image.lua
local arg = ffi.new("const double[?]",{115.23})
--here 10 is used for 'plane2cylinder' method
local tt = handle_result(self, lib.MagickDistortImage(self.wand, 10, 1, arg, 1))