如何传递 DistortMethod?

how to pass DistortMethod?

我一直在使用名为MagickWand. In MagickDistortImage的ImageMagick的CAPI,我不知道如何传递第二个参数。下面是我的代码。

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))

在我上面的代码中,我不知道如何传递第二个参数。

我找到了解决方案。 const DistortMethod method,它接受枚举,所以我只需要将它定义为整数并传递整数值。所以我修改了我的代码。

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))