如何传递DistortMethod参数?

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

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

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

点赞
用户7234862
用户7234862

我找到了解决方法。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})
--这里使用10来表示“plane2cylinder”方法
local tt =  handle_result(self, lib.MagickDistortImage(self.wand, 10, 1, arg, 1))
2017-04-05 07:04:41