gpt4 book ai didi

c - 如何传递 DistortMethod?

转载 作者:太空宇宙 更新时间:2023-11-04 03:23:42 26 4
gpt4 key购买 nike

我一直在使用名为 MagickWand 的 ImageMagick 的 C API .在 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))

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

最佳答案

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

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

关于c - 如何传递 DistortMethod?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43139652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com